public void GetById_Repo_RepoSelectionReturned() { //arrange var testContext = CreateContextWithTestData(); var repo = new FakeGenericRepository(testContext); int id = 1; //act var entity = repo.GetById(id); //assert Assert.AreNotEqual(entity, null); Assert.AreEqual(entity.CarModelID, id); }
public void ShouldCallFindMethod() { //Arrange var id = 5; var techDbContext = new Mock <ITechrepoDbContext>(); var dbSetMock = new Mock <DbSet <AdvertCategory> >(); techDbContext.Setup(t => t.Set <AdvertCategory>()).Returns(dbSetMock.Object); var genericRepo = new FakeGenericRepository <AdvertCategory>(techDbContext.Object); //Act genericRepo.GetById(id); //Assert dbSetMock.Verify(d => d.Find(id), Times.Once); }