Esempio n. 1
0
        public async void CanDeleteAmenity()
        {
            //testing hotel management service
            DbContextOptions <AsyncInnDbContext> options =
                new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteAmenity").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                //arrange
                Amenities amenity = new Amenities();
                amenity.ID   = 1;
                amenity.Name = "toaster";

                //act
                AmenityManagementService amenityservice = new AmenityManagementService(context);

                await amenityservice.CreateAmenity(amenity);

                await amenityservice.DeleteAmenity(1);

                var result = context.Amenities.Any(am => am.ID == 1);
                //assert
                Assert.False(result);
            }
        }
Esempio n. 2
0
        public async void CanUpdateAmenity()
        {
            //testing hotel management service
            DbContextOptions <AsyncInnDbContext> options =
                new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("CreateAmenity").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                //arrange
                Amenities amenity = new Amenities();
                amenity.ID   = 1;
                amenity.Name = "toaster";

                amenity.Name = "breakfast included";

                //act
                AmenityManagementService amenityservice = new AmenityManagementService(context);

                await amenityservice.CreateAmenity(amenity);

                await amenityservice.UpdateAmenity(amenity);

                var result = context.Amenities.FirstOrDefault(a => a.ID == a.ID);
                //assert
                Assert.Equal(amenity, result);
            }
        }
Esempio n. 3
0
        public async void CanCreateAmenity()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("CreateAmen").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                // Arrange
                Amenities amen = new Amenities();
                amen.ID   = 1;
                amen.Name = "Sink";

                //Act
                AmenityManagementService amenServ = new AmenityManagementService(context);

                await amenServ.CreateAmenity(amen);

                var result = context.Amenities.FirstOrDefault(c => c.ID == amen.ID);
                //Assert
                Assert.Equal(amen, result);
            }
        }
Esempio n. 4
0
        public async void CanGetAmenity()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("GetAmenity").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                // Arrange
                Amenities amenities = new Amenities();
                amenities.ID   = 1;
                amenities.Name = "Test Amenity";

                // Act
                AmenityManagementService amenityManagementService = new AmenityManagementService(context);
                await amenityManagementService.CreateAmenity(amenities);

                var result = await amenityManagementService.GetAmenity(amenities.ID);

                // Assert
                Assert.Equal(amenities, result);
            }
        }
Esempio n. 5
0
        public async void CanDeleteAmenity()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteAmen").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                // Arrange
                Amenities amen = new Amenities();
                amen.ID   = 1;
                amen.Name = "Sink";

                //Act
                AmenityManagementService amenServ = new AmenityManagementService(context);
                await amenServ.CreateAmenity(amen);

                amenServ.DeleteAmenity(amen.ID);

                var result = await amenServ.GetAmenity(amen.ID);

                //Assert
                Assert.Null(result);
            }
        }
Esempio n. 6
0
        public async void CanDeleteAmenity()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteAmenity").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                // Arrange
                Amenities amenities = new Amenities();
                amenities.ID   = 1;
                amenities.Name = "Test Amenity";

                // Act
                AmenityManagementService amenityManagementService = new AmenityManagementService(context);
                await amenityManagementService.CreateAmenity(amenities);

                await amenityManagementService.DeleteAmenity(amenities.ID);

                var result = context.Amenities.FirstOrDefault(a => a.ID == amenities.ID);

                // Assert
                Assert.Null(result);
            }
        }