public void TestInsert() { Mock <IUnitOfWork> uowMock = new Mock <IUnitOfWork>(); Mock <IRepository <Post> > repoMock = new Mock <IRepository <Post> >(); SomeService service = new SomeService(uowMock.Object, repoMock.Object); service.Insert("TestInsert"); repoMock.Verify(m => m.Add(It.IsAny <Post>()), Times.Once()); }
public void TestInsert() { var dbsetMock = new Mock <DbSet <Post> >(); var uowMock = new Mock <SachaContextTestDouble>(); uowMock.Setup(m => m.Posts).Returns(dbsetMock.Object); var service = new SomeService(uowMock.Object); service.Insert("Some url"); dbsetMock.Verify(m => m.Add(It.IsAny <Post>()), Times.Once()); }