Пример #1
0
        public void CantGetLocationByTrainingCenterNotInDatabase()
        {
            // 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();
            string inValidTrainingCenter = "InValidTrainingCenter";
            //Act
            var GetLocationWithProviderResult = testLocationController.GetLocationByTrainingCenter(inValidTrainingCenter).Result.Value.ToList();

            //Assert
            Assert.AreEqual(GetLocationWithProviderResult.Count(), 0);
            ClearAllChanges();
        }
Пример #2
0
        public void CanGetLocationByTrainingCenterInDatabase()
        {
            // 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 GetLocationWithProviderResult = testLocationController.GetLocationByTrainingCenter(14.ToString()).Result.Value.ToList()[0];

            //Assert
            Assert.IsInstanceOfType(GetLocationWithProviderResult, typeof(Location));
            //Clearing Changes
            ClearAllChanges();
        }