public async void CanUpdateRoom() { Microsoft.EntityFrameworkCore.DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase ("CreateRoom").Options; using (AsyncInnDbContext context = new AsyncInnDbContext (options)) { //Arrange Room room = new Room(); room.ID = 1; room.Name = "Iron"; room.RoomLayout = Layout.OneBedroom; room.RoomLayout = Layout.TwoBedroom; //Act RoomManagementService roomService = new RoomManagementService(context); await roomService.CreateRoom(room); await roomService.UpdateRoom(room); var result = await context.Room.FirstOrDefaultAsync(h => h.ID == room.ID); Assert.Equal(room, result); } }
public async void CanUpdateRoom() { 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 = "Test Room"; room.Layout = Layout.Studio; // Act RoomManagementService roomManagementService = new RoomManagementService(context); await roomManagementService.CreateRoom(room); room.Layout = Layout.OneBedroom; await roomManagementService.UpdateRoom(room); var result = context.Rooms.FirstOrDefault(r => r.ID == room.ID); // Assert Assert.Equal(room, result); } }
public async void CanUpdateRoom() { DbContextOptions <HotelManagementDbContext> options = new DbContextOptionsBuilder <HotelManagementDbContext> ().UseInMemoryDatabase("RoomAmenity").Options; using (HotelManagementDbContext context = new HotelManagementDbContext(options)) { // arrange Room roomA = new Room(); roomA.ID = 1; roomA.Name = "basic"; roomA.RoomAmentitiesID = 1; // Act RoomManagementService Service = new RoomManagementService(context); await Service.CreateRoom(roomA); roomA.RoomAmentitiesID = 2; Service.UpdateRoom(roomA); // Assert Assert.Equal(2, roomA.RoomAmentitiesID); } }
public async void UpdateRoomWorks() { 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 = "quiller"; room.Layout = 1; // Act RoomManagementService service = new RoomManagementService(context); await service.CreateRoom(room); room.Name = "quillers"; await service.UpdateRoom(room); // Assert Assert.Equal("quillers", room.Name); } }