public async void CanReadAmenity() { //testing hotel management service DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("GetAmenity").Options; using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { //arrange Amenities amenity = new Amenities(); amenity.ID = 1; amenity.Name = "toaster"; //act AmenityManagementService amenityservice = new AmenityManagementService(context); await amenityservice.CreateAmenity(amenity); await amenityservice.GetAmenity(1); var result = context.Amenities.FirstOrDefault(a => a.ID == a.ID); //assert Assert.Equal(amenity, result); } }
public async void CanGetAmenity() { DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("GetAmenity").Options; using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { // Arrange Amenities amenities = new Amenities(); amenities.ID = 1; amenities.Name = "Test Amenity"; // Act AmenityManagementService amenityManagementService = new AmenityManagementService(context); await amenityManagementService.CreateAmenity(amenities); var result = await amenityManagementService.GetAmenity(amenities.ID); // Assert Assert.Equal(amenities, result); } }
public async void CanDeleteAmenity() { DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteAmen").Options; using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { // Arrange Amenities amen = new Amenities(); amen.ID = 1; amen.Name = "Sink"; //Act AmenityManagementService amenServ = new AmenityManagementService(context); await amenServ.CreateAmenity(amen); amenServ.DeleteAmenity(amen.ID); var result = await amenServ.GetAmenity(amen.ID); //Assert Assert.Null(result); } }