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

            using (AsyncInnDbContext context = new AsyncInnDbContext
                                                   (options))
            {
                //Arrange
                Room room = new Room();
                room.ID         = 1;
                room.Name       = "Iron";
                room.RoomLayout = Layout.OneBedroom;

                //Act
                RoomManagementService roomService = new RoomManagementService(context);
                await roomService.CreateRoom(room);

                await roomService.GetRoom(1);

                var result = await context.Room.FirstOrDefaultAsync(h => h.ID == room.ID);

                Assert.Equal(room, result);
            }
        }
Beispiel #2
0
        public async void CanGetRoom()
        {
            DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("GetRoom").Options;

            using (AsyncInnDbContext context = new AsyncInnDbContext(options))
            {
                // Arrange
                Room room = new Room();
                room.ID     = 1;
                room.Name   = "Test Room";
                room.Layout = Layout.Studio;

                // Act
                RoomManagementService roomManagementService = new RoomManagementService(context);
                await roomManagementService.CreateRoom(room);

                var result = await roomManagementService.GetRoom(room.ID);

                // Assert
                Assert.Equal(room, result);
            }
        }