I get a very odd Error when creating a List of Accessors.
I have a class Component
with a private List of Component
s. Since I want to test some of the classes behaviour regarding this list I use an Accessor of the Component
-class. Also I have some dependencies in the constructor of the class I want to avoid. Therefore I manually instantiate the list in a TestInitialize()
-Method
The TestInitialize()-Code looks like this:
private string _testIdentifier = "TestComponent";
private int _testConsist = 1;
private Component_Accessor _target;
[TestInitialize()]
public void MyTestInitialize()
{
_target = new Component_Accessor();
_target.Identifier = new ComponentIdentifier(_testIdentifier, _testConsist);
_target._inputComponents = new List<Component_Accessor>();
_target._outputComponents = new List<Component_Accessor>();
}
The Accessor-Code looks like this:
[Shadowing("_inputComponents")]
public List<Component_Accessor> _inputComponents { get; set; }
This compiles just fine but I get a RunTimeException:
The Object of the type "System.Collections.Generic.List'1[DT5_Training_Simulator.Model.Components.Component_Accessor]" can not be converted to the type "System.Collections.Generic.List'1[DT5_Training_Simulator.Model.Components.Component]"
Actually I'm quite at a loss here. Could anybody please tell me what I did wrong?