public void GetHabitatByName_MisspelledHabitatName_ExceptionExpected() { // Arrange var habitatName = "Eastss"; var habitats = GetMoqHabitats(); var contextMock = new Mock <DBContext>(); contextMock.Setup(h => h.Habitats).ReturnsDbSet(habitats); var logger = Mock.Of <ILogger <HabitatRepository> >(); var habitatRepository = new HabitatRepository(contextMock.Object, logger); // Act & Assert Assert.ThrowsAsync <Exception>(() => habitatRepository.GetHabitatByName(habitatName)); }
public void GetHabitatByName_FourDifferentHabitats_HabitatNameExpected(string inlineHabitatName, string expected) { // Arrange var habitats = GetMoqHabitats(); var contextMock = new Mock <DBContext>(); contextMock.Setup(h => h.Habitats).ReturnsDbSet(habitats); var logger = Mock.Of <ILogger <HabitatRepository> >(); var habitatRepository = new HabitatRepository(contextMock.Object, logger); // Act var testResult = habitatRepository.GetHabitatByName(inlineHabitatName); // Assert Assert.Equal(expected, testResult.Result.Name); }