Beispiel #1
0
        public async void UpdateAmenitiesWorks()
        {
            DbContextOptions <AsyncInnDbContext> options =
                new DbContextOptionsBuilder <AsyncInnDbContext>
                    ().UseInMemoryDatabase("UpdateAmenities").Options;

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

                // Act
                AmenetiesManagementService service = new AmenetiesManagementService(context);

                await service.CreateAmeneties(amenities);

                amenities.Name = "Bar";
                await service.UpdateAmeneties(amenities);

                // Assert
                Assert.Equal("Bar", amenities.Name);
            }
        }
Beispiel #2
0
        public async void DeleteAmenitiesWorksAgain()
        {
            DbContextOptions <AsyncInnDbContext> options =
                new DbContextOptionsBuilder <AsyncInnDbContext>
                    ().UseInMemoryDatabase("DeleteAmenities").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                // arrange
                Amenities amenities = new Amenities();
                amenities.Name = "Bar";
                amenities.ID   = 2;

                // Act
                AmenetiesManagementService service = new AmenetiesManagementService(context);

                await service.CreateAmeneties(amenities);

                await service.DeleteAmenities(2);

                var deleted = context.Amenities.FirstOrDefault(r => r.ID == amenities.ID);

                // Assert
                Assert.Null(deleted);
            }
        }
Beispiel #3
0
        public async void CreateAmenitiesWorks()
        {
            DbContextOptions <AsyncInnDbContext> options =
                new DbContextOptionsBuilder <AsyncInnDbContext>
                    ().UseInMemoryDatabase("CreateAmenities").Options;

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

                // Act
                AmenetiesManagementService service = new AmenetiesManagementService(context);

                await service.CreateAmeneties(amenities);

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

                // Assert
                Assert.Equal(amenities, created);
            }
        }