Пример для модульного тестирования: < /p>
Код: Выделить всё
mockObject
.Setup(p => p.myTest(It.IsAny()))
.ReturnsAsync((object test) =>
{
var item = new
{
val1 = "123",
val2 = "abc",
val3 = testEntity
};
var response = new Mock();
response.Setup(r => r.Resource).Returns(item);
return response.Object;
});
< /code>
myTestКод: Выделить всё
public async TaskmyTest(TestEntity testEntity)
{
var item = new
{
val1 = "123",
val2 = "abc",
val3 = testEntity
};
// object is of type 'Container'
var response = await object.myTest(item);
...
}
< /code>
The myTest function in the last line has a signature like so:
public abstract Task myTest(T item));
< /code>
The issue I'm getting is that the parameter in the function myTest takes in the anonymous object 'item', but I'm doing .Returns((object test)Подробнее здесь: https://stackoverflow.com/questions/794 ... t-paramter
Мобильная версия