'Setup Mock to return the same object, which I send to it?
I want to test some code:
public ViewModel FillClientCreateViewModel(ViewModel model){
model.Phone = new Phone { Name = "Test"};
model.Phone = _entityInitializer.FillViewModel(model.Phone);
}
I also want to setup FillViewModel to return the same object as I give to it.
My test:
entityInitMock.Setup(x => x.FillViewModel(It.IsAny<PhoneViewModel>())).Returns(It.IsAny<PhoneViewModel>());
var result = TestedInstance.FillClientCreateViewModel(CreateViewModel);
result.Phone.Name.ShouldBe("Test");
But in this case my test fell - because result.Phone.Name was cleaned by my mock.
How can I setup mock to just give me the same object which i give to it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
