Example #1
0
        public void GetCustomersVehicles_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.GetCustomersVehicles();
        }
        public void  GetAllCustomersVehicles()
        {
            // Arrange
            _mockCustomersRepo.Setup(rep => rep.All()).Returns(_vehicles.AsQueryable());
            _mockRepositoryProvider.Setup(rep => rep.GetRepositoryForEntityType <Vehicle>()).Returns(_mockCustomersRepo.Object);
            _vehicleServiceUow = new VehicleServiceUOW(_mockRepositoryProvider.Object, _mockLogger);

            // Act
            var result = _vehicleServiceUow.GetCustomersVehicles(null, null, 60);

            // Assert
            Assert.IsInstanceOfType(result, typeof(IEnumerable <VehicleDTO>));
            Assert.AreEqual(7, result.Count);
        }
Example #3
0
        public void GetCustomersVehicles_ReturnsListOfCustomersDTOs_WithAnyRequest()
        {
            // Arrange
            _mockCustomersRepo.Setup(rep => rep.All()).Returns(_customers.AsQueryable());
            _mockRepositoryProvider.Setup(rep => rep.GetRepositoryForEntityType <Customer>()).Returns(_mockCustomersRepo.Object);
            _vehicleServiceUow = new VehicleServiceUOW(_mockRepositoryProvider.Object, _mockLogger);

            // Act
            var result = _vehicleServiceUow.GetCustomersVehicles();

            // Assert
            Assert.IsInstanceOfType(result, typeof(IEnumerable <CustomerDTO>));
            Assert.AreEqual(3, result.Count);
        }
        public void GetCustomerVehiclesByCusID()
        {
            // Arrange
            _mockCustomersRepo.Setup(rep => rep.All()).Returns(_vehicles.AsQueryable());
            _mockRepositoryProvider.Setup(rep => rep.GetRepositoryForEntityType <Vehicle>()).Returns(_mockCustomersRepo.Object);
            _vehicleServiceUow = new VehicleServiceUOW(_mockRepositoryProvider.Object, _mockLogger);

            int cus_id = 1;

            // Act
            var result = _vehicleServiceUow.GetCustomersVehicles(cus_id, null, 60);

            // Assert
            Assert.IsInstanceOfType(result, typeof(IEnumerable <VehicleDTO>));
            string vins    = _vehicles.Where(v => v.CustomerId == 1).Select(i => i.VIN).Aggregate((i, j) => i + "," + j);
            string resvins = result.Select(i => i.VIN).Aggregate((i, j) => i + "," + j);

            Assert.AreEqual(vins, resvins);
        }