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

            using AsyncInnDbContext context = new AsyncInnDbContext(options);

            AmenityManager service = new AmenityManager(context);

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

            await service.UpdateAmenity(new AmenityDto()
            {
                Id = 1, Name = "Test Two"
            });

            var actual = await service.GetAmenity(1);

            Assert.Equal(1, await context.Amenities.CountAsync());
            Assert.NotEqual("Test One", actual.Name);
            Assert.Equal("Test Two", actual.Name);
        }
Beispiel #2
0
        public async void CanGetAmenityFromDatabase()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>()
                                                           .UseInMemoryDatabase("CanGetAmenityFromDatabase")
                                                           .Options;

            using AsyncInnDbContext context = new AsyncInnDbContext(options);

            AmenityManager service = new AmenityManager(context);

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

            var actual = await service.GetAmenity(result.Id);

            Assert.IsType <AmenityDto>(actual);
            Assert.Equal(1, actual.Id);
            Assert.Equal("Test", actual.Name);
        }