public async void CanDeleteAmenity() { //testing hotel management service DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteAmenity").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.DeleteAmenity(1); var result = context.Amenities.Any(am => am.ID == 1); //assert Assert.False(result); } }
public async void CanUpdateAmenity() { //testing hotel management service DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("CreateAmenity").Options; using (AsyncInnDbContext context = new AsyncInnDbContext(options)) { //arrange Amenities amenity = new Amenities(); amenity.ID = 1; amenity.Name = "toaster"; amenity.Name = "breakfast included"; //act AmenityManagementService amenityservice = new AmenityManagementService(context); await amenityservice.CreateAmenity(amenity); await amenityservice.UpdateAmenity(amenity); var result = context.Amenities.FirstOrDefault(a => a.ID == a.ID); //assert Assert.Equal(amenity, result); } }
public async void CanCreateAmenity() { DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("CreateAmen").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); var result = context.Amenities.FirstOrDefault(c => c.ID == amen.ID); //Assert Assert.Equal(amen, 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); } }
public async void CanDeleteAmenity() { DbContextOptions <AsyncInnDbContext> options = new DbContextOptionsBuilder <AsyncInnDbContext>().UseInMemoryDatabase("DeleteAmenity").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); await amenityManagementService.DeleteAmenity(amenities.ID); var result = context.Amenities.FirstOrDefault(a => a.ID == amenities.ID); // Assert Assert.Null(result); } }