Welcome! Log In Create A New Profile

Advanced

[WD23] Compare Two Interfaces

[WD23] Compare Two Interfaces
December 02, 2019 03:33PM
Hello everyone,

I am trying to compare two class interface in WEBDEV, but I believe that WLanguage doesn't support this feature. The following code is one of my unit test that make sure the instantiation of the tested class, SuccessResponse, works.

PROCÉDURE Intantiate()

_code is int = 10
_type is string = "success"
_information is string = "Everything worked !"
_content is array of IResponseResult
_content.Add(new Entity())
_content.Add(new Entity())
_content.Add(new Entity())

_response is IResponse <- new SuccessResponse(_code, _type, _information, _content)

TestCheckEqual(_response.Code, _code)
TestCheckEqual(_response.Type, _type)
TestCheckEqual(_response.Information, _information)
TestCheckEqual(_response.Content..Occurrence, _content..Occurrence) // I'm only comparing the number of element, because WLanguage can't compare two interfaces.

The main source of problem is the _content variable, which is an array of interfaces called IResponseResult. For testing purposes, I am adding three object of type Entity, which is a class that implements the IResponseResult. So far so good, the objects are added the the array.

The problem appears at the last TestCheckEqual call, where I pass two array of IResponseResult. When they are compared, WLanguage throws an exception saying : "The assignment of an interface is prohibited. Use the <- operator to reference an interface.".

If someone has a solution to this, it would be very useful !

Thank you
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: