public async Task GetViewModelByIdAsync_WithExistentId_ShouldReturnCorrectResult() { var errorMessagePrefix = "ReservationStatusesService GetViewModelByIdAsync() method does not work properly."; // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context); var reservationStatusesService = this.GetReservationStatusesService(reservationStatusRepository, context); var seeder = new ReservationStatusesServiceTestsSeeder(); await seeder.SeedReservationStatusesAsync(context); var reservationStatusId = reservationStatusRepository.All().First().Id; // Act var actualResult = await reservationStatusesService.GetViewModelByIdAsync <EditReservationStatusViewModel>(reservationStatusId); var expectedResult = new EditReservationStatusViewModel { Id = reservationStatusId, Name = reservationStatusRepository.All().First().Name, }; // Assert Assert.True(expectedResult.Id == actualResult.Id, errorMessagePrefix + " " + "Id is not returned properly."); Assert.True(expectedResult.Name == actualResult.Name, errorMessagePrefix + " " + "Name is not returned properly."); }
public async Task CreateAllAsync_ShouldShouldSuccessfullyCreate() { var errorMessagePrefix = "ReservationStatusesService CreateAllAsync() method does not work properly."; // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context); var reservationStatusesService = this.GetReservationStatusesService(reservationStatusRepository, context); var seeder = new ReservationStatusesServiceTestsSeeder(); await seeder.SeedReservationStatusesAsync(context); // Act var result = await reservationStatusesService.CreateAllAsync(new string[] { "Test-1", "Test-2", "Test-3" }); // Assert Assert.True(result, errorMessagePrefix + " " + "Returns false."); }
public async Task GetAllReservationStatusesCountAsync_ShouldReturnCorrectResult() { var errorMessagePrefix = "ReservationStatusesService GetAllReservationStatusesCountAsync() method does not work properly."; // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context); var reservationStatusesService = this.GetReservationStatusesService(reservationStatusRepository, context); var seeder = new ReservationStatusesServiceTestsSeeder(); await seeder.SeedReservationStatusesAsync(context); // Act var actualResult = await reservationStatusesService.GetAllReservationStatusesCountAsync(); var expectedResult = reservationStatusRepository.All().Count(); // Assert Assert.True(actualResult == expectedResult, errorMessagePrefix + " " + "ReservationStatusesService GetAllReservationStatusesCountAsync() method does not work properly."); }
public async Task DeleteByIdAsync_WithExistentId_ShouldReturnCorrectResult() { var errorMessagePrefix = "ReservationStatusesService DeleteByIdAsync() method does not work properly."; // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var reservationStatusRepository = new EfDeletableEntityRepository <ReservationStatus>(context); var reservationStatusesService = this.GetReservationStatusesService(reservationStatusRepository, context); var seeder = new ReservationStatusesServiceTestsSeeder(); await seeder.SeedReservationStatusesAsync(context); var reservationStatusId = reservationStatusRepository.All().First().Id; // Act var result = await reservationStatusesService.DeleteByIdAsync(reservationStatusId); // Assert Assert.True(result, errorMessagePrefix + " " + "Returns false."); }