Hello,I'm using NSubstitute 1.4.0.0. I try to test my method: GetMyEntities(string myId). But, I have this exception: "Expected to receive exactly 1 call matching: LoadData(any GetCommand) Actually received no matching calls.", when my ReceivedWithAnyArgs assertion for LoadData method is called. Have you got an idea to solve it ? Please help me.
- My Code:
public class DataAccessLayer : IDataAccessLayer, IDisposable
{
private IBusinessEntities dataFacade;public DataAccessLayer(IBusinessEntities facade)
{
dataFacade = facade;
}public MyEntities GetMyEntities(string myId)
{
GetAllMyEntities getMyEntities = new GetAllMyEntities();
getMyEntities.Id = myId;
dataFacade.LoadData(getMyEntities);
return dataFacade.Get<MyEntities>();
}
}public interface IBusinessEntities
{T Get<T>() where T : BusinessEntitiesBase, new();void LoadData(GetCommand commandName);}
- My Test:
public void GetMyEntitiesOK_UndefinedParam_MyEntitiesIsSame()
{
//Given
var mockFacade = Substitute.For<IBusinessEntities>();
var concreteDal = new DataAccessLayer(mockFacade);
MyEntities expected = new MyEntities();//Expect
mockFacade.Get<MyEntities>().ReturnsForAnyArgs(expected);//When
MyEntities actual = concreteDal.GetMyEntities(Arg.Any<string>());//Then
Assert.AreSame(expected, actual);
mockFacade.ReceivedWithAnyArgs(1).LoadData(Arg.Any<GetCommand>()); //exception????
mockFacade.ReceivedWithAnyArgs(1).Get<MyEntities>();
}--
You received this message because you are subscribed to the Google Groups "NSubstitute" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nsubstitute/-/0Izru44BMMAJ.
To post to this group, send email to nsubs...@googlegroups.com.
To unsubscribe from this group, send email to nsubstitute...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nsubstitute?hl=en.
To unsubscribe from this group, send email to nsubstitute+unsubscribe@googlegroups.com.