public async Task GetAllRoomTypesAsyn_ShouldReturnCorrectCount() { // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var seeder = new RoomTypesServiceTestsSeeder(); await seeder.SeedRoomTypeAsync(context); var roomTypeRepository = new EfDeletableEntityRepository <RoomType>(context); var roomTypesService = this.GetRoomTypesService(roomTypeRepository, context); // Act var actualResult = roomTypesService.GetAllRoomTypes <DetailsRoomTypeViewModel>().ToList(); var expectedResult = new DetailsRoomTypeViewModel[] { new DetailsRoomTypeViewModel { Id = roomTypeRepository.All().First().Id, Name = roomTypeRepository.All().First().Name, CapacityAdults = roomTypeRepository.All().First().CapacityAdults, CapacityKids = roomTypeRepository.All().First().CapacityKids, Image = roomTypeRepository.All().First().Image, Description = roomTypeRepository.All().First().Description, }, }; Assert.Equal(expectedResult.Length, actualResult.Count()); }
public async Task GetAllRoomTypesAsyn_ShouldReturnCorrectResult() { var errorMessagePrefix = "RoomTypesService GetAllRoomTypesAsyn() method does not work properly."; // Arrange MapperInitializer.InitializeMapper(); var context = HotelDbContextInMemoryFactory.InitializeContext(); var seeder = new RoomTypesServiceTestsSeeder(); await seeder.SeedRoomTypeAsync(context); var roomTypeRepository = new EfDeletableEntityRepository <RoomType>(context); var roomTypesService = this.GetRoomTypesService(roomTypeRepository, context); // Act var actualResult = roomTypesService.GetAllRoomTypes <DetailsRoomTypeViewModel>().ToList(); var expectedResult = new DetailsRoomTypeViewModel[] { new DetailsRoomTypeViewModel { Id = roomTypeRepository.All().First().Id, Name = roomTypeRepository.All().First().Name, CapacityAdults = roomTypeRepository.All().First().CapacityAdults, CapacityKids = roomTypeRepository.All().First().CapacityKids, Image = roomTypeRepository.All().First().Image, Description = roomTypeRepository.All().First().Description, Price = roomTypeRepository.All().First().Price, }, }; 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."); Assert.True(expectedResult[0].Price == actualResult[0].Price, errorMessagePrefix + " " + "Price is not returned properly."); Assert.True(expectedResult[0].CapacityAdults == actualResult[0].CapacityAdults, errorMessagePrefix + " " + "Capacity Adults is not returned properly."); Assert.True(expectedResult[0].CapacityKids == actualResult[0].CapacityKids, errorMessagePrefix + " " + "Capacity Kids is not returned properly."); Assert.True(expectedResult[0].Image == actualResult[0].Image, errorMessagePrefix + " " + "Image is not returned properly."); Assert.True(expectedResult[0].Description == actualResult[0].Description, errorMessagePrefix + " " + "Description is not returned properly."); }