Ejemplo n.º 1
0
        public async void CanDeleteRoom()
        {
            //testing hotel management service
            DbContextOptions <AsyncInnDbContext> options =
                new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteRoom").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                //arrange
                Room room = new Room();
                room.ID     = 1;
                room.Name   = "Downtown";
                room.Layout = 0;

                //act
                RoomMangementService roomservice = new RoomMangementService(context);

                await roomservice.CreateRoom(room);

                await roomservice.DeleteRoom(1);

                var result = context.Rooms.Any(rm => rm.ID == 1);
                //assert
                Assert.False(result);
            }
        }
Ejemplo n.º 2
0
        public async void CanUpdateRoom()
        {
            //testing hotel management service
            DbContextOptions <AsyncInnDbContext> options =
                new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("UpdateRoom").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                //arrange
                Room room = new Room();
                room.ID     = 1;
                room.Name   = "Downtown";
                room.Layout = 0;

                room.Name   = "Space Needle";
                room.Layout = 2;

                //act
                RoomMangementService roomservice = new RoomMangementService(context);

                await roomservice.CreateRoom(room);

                await roomservice.UpdateRoom(room);

                var result = context.Rooms.FirstOrDefault(r => r.ID == r.ID);
                //assert
                Assert.Equal(room, result);
            }
        }