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

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                Room room = new Room();
                room.ID     = 62;
                room.Name   = "Hawks";
                room.Layout = Layouts.OneBedroom;

                RoomManagementServices roomService = new RoomManagementServices(context);

                await roomService.CreateRoom(room);

                Room upRoom = await roomService.GetRooms(room.ID);

                upRoom.Layout = Layouts.TwoBedroom;

                await roomService.UpdateRooms(upRoom);

                var result = context.Room.FirstOrDefault(ho => ho.ID == room.ID);

                Assert.Equal(Layouts.TwoBedroom, result.Layout);
            }
        }
Example #2
0
        public async void CanDeleteRoom()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteRoom").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                Room room = new Room();
                room.ID     = 61;
                room.Name   = "Hawks";
                room.Layout = Layouts.OneBedroom;

                RoomManagementServices roomService = new RoomManagementServices(context);

                await roomService.CreateRoom(room);

                await roomService.DeleteRoom(room.ID);

                var result = context.Room.FirstOrDefault(ho => ho.ID == room.ID);

                Assert.Null(result);
            }
        }