public void GetCustomerVehiclesByCustomerId_ReturnsException_WithInternalExceptionOccures() { //Arrange _mockCustomersRepo.Setup(rep => rep.All()).Throws <Exception>(); _mockRepositoryProvider.Setup(rep => rep.GetRepositoryForEntityType <Customer>()).Returns(_mockCustomersRepo.Object); _vehicleServiceUow = new VehicleServiceUOW(_mockRepositoryProvider.Object, _mockLogger); // Act _vehicleServiceUow.GetCustomersVehiclesByStatus(true); }
public void GetCustomersVehiclesByStatus_ReturnsListOfCustomersDTOs_WithSpecificStatus() { // Arrange _mockCustomersRepo.Setup(rep => rep.All()).Returns(_customersWithConnectedVehicles.AsQueryable()); _mockRepositoryProvider.Setup(rep => rep.GetRepositoryForEntityType <Customer>()).Returns(_mockCustomersRepo.Object); _vehicleServiceUow = new VehicleServiceUOW(_mockRepositoryProvider.Object, _mockLogger); // Act var result = _vehicleServiceUow.GetCustomersVehiclesByStatus(true); // Assert Assert.IsInstanceOfType(result, typeof(IEnumerable <CustomerDTO>)); Assert.AreEqual(3, result.Count); }
public void GetCustomersVehiclesByStatus_ReturnsListOfCustomersDTOs_WithVehiclesListDTOsForEachCustomer_EachVehicleHasTheSameSentStatus() { // Arrange _mockCustomersRepo.Setup(rep => rep.All()).Returns(_customersWithConnectedVehicles.AsQueryable()); _mockRepositoryProvider.Setup(rep => rep.GetRepositoryForEntityType <Customer>()).Returns(_mockCustomersRepo.Object); _vehicleServiceUow = new VehicleServiceUOW(_mockRepositoryProvider.Object, _mockLogger); // Act var result = _vehicleServiceUow.GetCustomersVehiclesByStatus(true); // Assert Assert.AreEqual(3, result.Count); Assert.AreEqual(2, result[0].Vehicles.Where(v => v.CurrentStatus).Count()); Assert.AreEqual(1, result[1].Vehicles.Where(v => v.CurrentStatus).Count()); Assert.AreEqual(1, result[2].Vehicles.Where(v => v.CurrentStatus).Count()); }