public void CanGetAllLocationsInDatabase() { // Arrange Everything We Need For Our Unit Tests options = new DbContextOptionsBuilder <ApplicationDBContext>() .UseInMemoryDatabase(databaseName: "TestRevatureHousingData") .Options; testContext = new ApplicationDBContext(options); dummyLocationsData = new LocationDummyData(); dummyLocations = dummyLocationsData.LocationsList; testLocationRepository = new LocationRepository(testContext); testLocationController = new LocationsController(testLocationRepository); dummyConstantLocation = new Location() { LocationID = 3 }; //Arrange Populate(); //Act var allLocations = testLocationController.GetLocation().Result.ToList(); var allDummyLocations = dummyLocations.Count; Assert.AreEqual(allLocations.Count, allDummyLocations); //Clearing Changes ClearAllChanges(); }
public void CantGetLocationInEmptyDatabase() { // Arrange Everything We Need For Our Unit Tests options = new DbContextOptionsBuilder <ApplicationDBContext>() .UseInMemoryDatabase(databaseName: "TestRevatureHousingData") .Options; testContext = new ApplicationDBContext(options); dummyLocationsData = new LocationDummyData(); dummyLocations = dummyLocationsData.LocationsList; testLocationRepository = new LocationRepository(testContext); testLocationController = new LocationsController(testLocationRepository); dummyConstantLocation = new Location() { LocationID = 3 }; //Act var getLocationResult = testLocationController.GetLocation(8191).Result.Value; //Assert Assert.AreEqual(getLocationResult, null); ClearAllChanges(); }