Код: Выделить всё
//in project MyProj
class TypeA
{
private List myList = new List();
private class TypeB
{
public TypeB()
{
}
}
public TypeA()
{
}
private void MyFunc()
{
//processing of myList that changes state of instance
}
}
//in project TestMyProj
public void MyFuncTest()
{
TypeA_Accessor target = new TypeA_Accessor();
//following line is the one that throws exception
target.myList.Add(new TypeA_Accessor.TypeB());
target.MyFunc();
//check changed state of target
}
Код: Выделить всё
Object of type System.Collections.Generic.List`1[MyProj.TypeA.TypeA_Accessor+TypeB]' cannot be converted to type 'System.Collections.Generic.List`1[MyProj.TypeA.TypeA+TypeB]'.
Можно ли как-нибудь устранить эту ошибку? Или, что более вероятно, какие еще советы могут дать другие люди (я предсказываю, что, возможно, «не тестируйте частные методы» и «не позволяйте модульным тестам манипулировать состоянием объектов»).
Подробнее здесь: https://stackoverflow.com/questions/912 ... in-c-sharp