Re: Как подменить конструктор класса в microsoft.fakes ?
От: Sinix  
Дата: 18.09.12 08:03
Оценка: 3 (1)
Здравствуйте, romca, Вы писали:

R>Что бы он возвращал ShimMyObject. Может кто в курсе как это делаться?

Если верить документации, то как-то так:
// code under test
public class MyClass {
    public MyClass(int value) {
        this.Value = value;
    }
    ...
}

// ...

// unit test code
// We set up the shim type of the constructor so that every future instance returns -5 when the Value getter is invoked, regardless of the value in the constructor:
ShimMyClass.ConstructorInt32 = (@this, value) =>
{
    var shim = new ShimMyClass(@this)
    {
        ValueGet = () => -5
    };
};
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.