public async Task GetAllPaymentTypesAsyn_ShouldReturnCorrectResult() { var errorMessagePrefix = "PaymentTypesService GetAllPaymentTypesAsyn() method does not work properly."; // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var paymentTypeRepository = new EfDeletableEntityRepository <PaymentType>(context); var paymentTypesService = this.GetPaymentTypesService(paymentTypeRepository); var seeder = new PaymentTypesServiceTestsSeeder(); await seeder.SeedPaymentTypesAsync(context); // Act var actualResult = paymentTypesService.GetAllPaymentTypes <DetailsPaymentTypeViewModel>().ToList(); var expectedResult = new DetailsPaymentTypeViewModel[] { new DetailsPaymentTypeViewModel { Id = paymentTypeRepository.All().First().Id, Name = paymentTypeRepository.All().First().Name, }, }; Assert.True(expectedResult[0].Id == actualResult[0].Id, errorMessagePrefix + " " + "Id is not returned properly."); Assert.True(expectedResult[0].Name == actualResult[0].Name, errorMessagePrefix + " " + "Name is not returned properly."); }
public async Task GetAllPaymentTypesAsyn_ShouldReturnCorrectCount() { // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var paymentTypeRepository = new EfDeletableEntityRepository <PaymentType>(context); var paymentTypesService = this.GetPaymentTypesService(paymentTypeRepository); var seeder = new PaymentTypesServiceTestsSeeder(); await seeder.SeedPaymentTypeAsync(context); // Act var actualResult = paymentTypesService.GetAllPaymentTypes <DetailsPaymentTypeViewModel>().ToList(); var expectedResult = new DetailsPaymentTypeViewModel[] { new DetailsPaymentTypeViewModel { Id = paymentTypeRepository.All().First().Id, Name = paymentTypeRepository.All().First().Name, }, }; Assert.Equal(expectedResult.Length, actualResult.Count()); }