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

            using AsyncInnDbContext context = new AsyncInnDbContext(options);

            AmenityManager service = new AmenityManager(context);

            Assert.Equal(0, await context.Amenities.CountAsync());

            _ = await service.CreateAmenity(new AmenityDto()
            {
                Name = "Test"
            });

            Assert.Equal(1, await context.Amenities.CountAsync());

            await service.DeleteAmenity(1);

            Assert.Equal(0, await context.Amenities.CountAsync());
        }