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); } }
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); } }