Пример #1
0
        public async Task GetLocationsAsync_CheckforNotFound()
        {
            //Arrange
            var testLocations = Array.Empty <Location>();

            _locationRepoMock.Setup(x => x.GetLocationsAsync())
            .ReturnsAsync(testLocations);

            //Act
            var result = await _testController.GetLocations();

            //Assert
            var actionResult = Assert.IsType <ActionResult <IEnumerable <Location> > >(result);

            Assert.IsType <NotFoundResult>(actionResult.Result);
        }
        public void TestGetLocationById(int _id, string _name)
        {
            string   expectedName = _name;
            int      id           = _id;
            var      controller   = new LocationsController(_locationsFacade);
            Location result       = controller.GetLocations(_id);

            Assert.Equal(expectedName, result.Name);
        }
Пример #3
0
        public async System.Threading.Tasks.Task CanChangeMeasuremenatHumidityAsync()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase("test")
                          .Options;

            using var db = new ApplicationDbContext(options);
            Location l = new Location
            {
                Latitude  = 12.2,
                Longitude = 192.1,
                Name      = "test1"
            };
            LocationsController _uut = new LocationsController(db);
            await _uut.PostLocation(l);

            var data = await _uut.GetLocations();

            Assert.NotEmpty(data.Value);
        }
Пример #4
0
        public void getLocationsTest()
        {
            var option = CreateNewContextOptions();

            using (var context = new BackendDBContext(option))
            {
                Facility facility = new Facility();
                facility.Name     = "test";
                facility.Created  = DateTime.Now;
                facility.Modified = DateTime.Now;
                context.facilities.Add(facility);
                try
                {
                    context.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    throw;
                }
                LocationFacility locationFacility = new LocationFacility();
                locationFacility.FacilityID       = facility.ID;
                locationFacility.FacilityInstance = facility;
                locationFacility.Created          = DateTime.Now;
                locationFacility.Modified         = DateTime.Now;
                locationFacility.Value            = "Test";

                context.LocationFacilities.Add(locationFacility);
                try
                {
                    context.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    throw;
                }
                Location location = new Location();
                location.LocationFacilities = new List <LocationFacility>();
                location.LocationFacilities.Add(locationFacility);
                location.Name         = "test";
                location.Latitude     = 1.10;
                location.Longitude    = 1.10;
                location.OpeningHours = "test";
                location.Phonenumber  = "test";
                location.Postcode     = "test";
                location.Created      = DateTime.Now;
                location.Modified     = DateTime.Now;

                context.Locations.Add(location);
                try
                {
                    context.SaveChanges();
                }
                catch (DbUpdateException)
                {
                    throw;
                }
                var target = new LocationsController(context);
                var result = target.GetLocations();
                int count  = 1;
                Assert.AreEqual(count, result.Count());
            }
        }