public void GetFamilyById_ReturnsFamilyWithId() { using (var context = new TestHedwigContextProvider().Context) { var family = FamilyHelper.CreateFamily(context); var familyRepo = new FamilyRepository(context); var res = familyRepo.GetFamilyById(family.Id); Assert.Equal(family.Id, res.Id); } }
public void GetFamilyById_ExpectedNotNull_EqualsActual() { // Arrange var contextMock = new Mock <DBContext>(); contextMock.Setup(f => f.Families).ReturnsDbSet(GetTestFamilies()); var logger = Mock.Of <ILogger <FamilyRepository> >(); var familyRepository = new FamilyRepository(contextMock.Object, logger); var id = 2; var actual = GetTestFamilies()[1]; // Act var expected = familyRepository.GetFamilyById(id); // Assert Assert.NotNull(expected.Result); Assert.Equal(expected.Result.Name, actual.Name); }