public async Task GetAllUserRequests_ShouldReturnCorrectCount() { // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var userRequestRepository = new EfDeletableEntityRepository <UserRequest>(context); var userRequestsService = this.GetUserRequestService(userRequestRepository); var seeder = new UserRequestsTestsSeeder(); await seeder.SeedUserRequestAsync(context); // Act var actualResult = userRequestsService.GetAllUserRequests <DetailsUserRequestViewModel>().ToList(); var expectedResult = new DetailsUserRequestViewModel[] { new DetailsUserRequestViewModel { Id = userRequestRepository.All().First().Id, Email = userRequestRepository.All().First().Email, Content = userRequestRepository.All().First().Content, Title = userRequestRepository.All().First().Title, }, }; Assert.Equal(expectedResult.Length, actualResult.Count()); }
public async Task GetAllUserRequests_ShouldReturnCorrectResult() { var errorMessagePrefix = "UserRequestsService GetAllUserRequests() method does not work properly."; // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var userRequestRepository = new EfDeletableEntityRepository <UserRequest>(context); var userRequestsService = this.GetUserRequestService(userRequestRepository); var seeder = new UserRequestsTestsSeeder(); await seeder.SeedUserRequestsAsync(context); // Act var actualResult = userRequestsService.GetAllUserRequests <DetailsUserRequestViewModel>().ToList(); var expectedResult = new DetailsUserRequestViewModel[] { new DetailsUserRequestViewModel { Id = userRequestRepository.All().First().Id, Email = userRequestRepository.All().First().Email, Content = userRequestRepository.All().First().Content, Title = userRequestRepository.All().First().Title, }, }; Assert.True(expectedResult[0].Id == actualResult[0].Id, errorMessagePrefix + " " + "Id is not returned properly."); Assert.True(expectedResult[0].Title == actualResult[0].Title, errorMessagePrefix + " " + "Title is not returned properly."); Assert.True(expectedResult[0].Content == actualResult[0].Content, errorMessagePrefix + " " + "Conteny is not returned properly."); Assert.True(expectedResult[0].Email == actualResult[0].Email, errorMessagePrefix + " " + "Email is not returned properly."); }