public OrderController(IOrderMapper orderMapper, ICustomerMapper customerMapper, IProductMapper productMapper, IOrderDetailMapper orderDetailMapper)
 {
     _orderDetailMapper = orderDetailMapper;
     _OrderMapper       = orderMapper;
     _customerMapper    = customerMapper;
     _productMapper     = productMapper;
 }
 public CustomerDataAgent(ICustomerRepository customerRepository, ICustomerMapper customerMapper, IAccountMapper accountMapper, ILoanMapper loanMapper)
 {
     _customerRepository = customerRepository;
     _customerMapper     = customerMapper;
     _accountMapper      = accountMapper;
     _loanMapper         = loanMapper;
 }
        public void ShouldFindOriginalAndPassModifiedToRepository()
        {
            ICustomerRepository repository = Substitute.For <ICustomerRepository>();
            Customer            original   = new Customer();

            setReturnedCustomer(repository, original);

            ICustomerMapper mapper    = Substitute.For <ICustomerMapper>();
            Customer        modified  = new Customer();
            CustomerData    viewModel = new CustomerData()
            {
                CustomerId = Guid.Empty.ToString("N")
            };

            mapper.Convert(Arg.Any <CustomerData>()).Returns(modified);

            CustomerAdapter adapter = new CustomerAdapter(repository)
            {
                CustomerMapper = mapper
            };

            adapter.UpdateCustomer(viewModel);

            repository.Received().GetCustomer(Arg.Any <Guid>());
            mapper.Received().Convert(viewModel);
            repository.Received().Update(original, modified);
        }
Esempio n. 4
0
 public InvoiceController(IInvoiceMapper invoice, IOrderDetailMapper orderDetailMapper, ICustomerMapper customer, ICompanyMapper companyMapper, IOrderMapper orderMapper)
 {
     _invoiceMapper      = invoice;
     _iOrderDetailMapper = orderDetailMapper;
     _customerMapper     = customer;
     _companyMapper      = companyMapper;
     _orderMapper        = orderMapper;
 }
Esempio n. 5
0
 public CustomerRepository(ICustomerMapper <T> mapper)
 {
     if (mapper == null)
     {
         throw new ArgumentNullException(nameof(mapper));
     }
     _mapper = mapper;
 }
Esempio n. 6
0
 public CustomerService(ICustomerRepository customerRepository,
                        ICustomerMapper customerMapper,
                        IOrderRepository orderRepository)
 {
     _customerRepository = customerRepository;
     _customerMapper     = customerMapper;
     _orderRepository    = orderRepository;
 }
 public CustomerService(ICustomerDomainService customerDomainService, ICustomerDataAgent customerDataAgent, ICustomerMapper customerMapper, IAccountMapper accountMapper, ILoanMapper loanMapper, ILogger logger)
 {
     _customerDomainService = customerDomainService;
     _customerDataAgent     = customerDataAgent;
     _customerMapper        = customerMapper;
     _accountMapper         = accountMapper;
     _loanMapper            = loanMapper;
     _logger = logger;
 }
        public CustomerMapperTests()
        {
            //setup our dependency injection so we can find desired implementations

            var serviceProvider = new ServiceCollection()
                                  .AddSingleton <ICustomerMapper, CustomerMapperService>()
                                  .AddSingleton <ILogger, MockLoggerService>()
                                  .BuildServiceProvider();

            mapper = serviceProvider.GetService <ICustomerMapper>();
            logger = serviceProvider.GetService <ILogger>(); // singleton
        }
        public void ShouldGetCustomersFromRepository()
        {
            ICustomerRepository repository = Substitute.For <ICustomerRepository>();

            Customer[] customers = new Customer[] { new Customer() };
            repository.GetCustomers().Returns(customers);

            ICustomerMapper mapper = Substitute.For <ICustomerMapper>();

            mapper.Convert(Arg.Any <Customer>()).Returns(new CustomerData());

            CustomerAdapter adapter = new CustomerAdapter(repository)
            {
                CustomerMapper = mapper
            };
            IEnumerable <CustomerData> results = adapter.GetCustomers();

            repository.Received().GetCustomers();
            mapper.Received(1).Convert(customers[0]);

            Assert.IsNotNull(results, "Null was returned by the adapter.");
            Assert.AreEqual(1, results.Count(), "The wrong number of view models were returned.");
        }
        public void ShouldAddConvertedCustomerToRepositoryAndReturnUpdated()
        {
            ICustomerRepository repository      = Substitute.For <ICustomerRepository>();
            ICustomerMapper     mapper          = Substitute.For <ICustomerMapper>();
            Customer            dto             = new Customer();
            CustomerData        viewModelInput  = new CustomerData();
            CustomerData        viewModelOutput = new CustomerData();

            mapper.Convert(viewModelInput).Returns(dto);
            mapper.Convert(dto).Returns(viewModelOutput);

            CustomerAdapter adapter = new CustomerAdapter(repository)
            {
                CustomerMapper = mapper
            };

            CustomerData result = adapter.AddCustomer(viewModelInput);

            Assert.AreSame(viewModelOutput, result, "The updated view model was not returned.");

            mapper.Received().Convert(viewModelInput);
            repository.Received().Add(dto);
            mapper.Received().Convert(dto);
        }
        public void ShouldMapCustomerToViewModel()
        {
            ICustomerRepository repository = Substitute.For <ICustomerRepository>();
            Customer            dto        = new Customer();

            setReturnedCustomer(repository, dto);

            ICustomerMapper mapper    = Substitute.For <ICustomerMapper>();
            CustomerData    viewModel = new CustomerData();

            mapper.Convert(dto).Returns(viewModel);

            CustomerAdapter adapter = new CustomerAdapter(repository)
            {
                CustomerMapper = mapper
            };
            PrimitiveMapper primitiveMapper = new PrimitiveMapper();
            CustomerData    data            = adapter.GetCustomer(primitiveMapper.ToString(Guid.Empty));

            repository.Received().GetCustomer(dto.CustomerId);
            mapper.Received().Convert(dto);

            Assert.IsNotNull(data, "The returned view model was null.");
        }
Esempio n. 12
0
 public CustomerService(ICustomerRepository customerRepository, ICustomerMapper customerMapper)
 {
     _customerRepository = customerRepository;
     _customerMapper     = customerMapper;
 }
Esempio n. 13
0
 public CustomerController(ICustomerMapper customerMapper, ICompanyMapper companyMapper)
 {
     _CustomerMapper = customerMapper;
     _companymapper  = companyMapper;
 }
Esempio n. 14
0
 public FileSystemService(ICustomerMapper customerMapperService, ILogger logger)
 {
     this.customerMapperService = customerMapperService;
     this.logger = logger;
 }
Esempio n. 15
0
 public CustomerService(ICustomerRepository repository, ICustomerMapper mapper, IOrderMapper orderMapper)
 {
     this.repository = repository;
     this.mapper = mapper;
     this.orderMapper = orderMapper;
 }
Esempio n. 16
0
 public CustomerRepository(ICustomerMapper customerMapper)
 {
     _customerMapper = customerMapper;
 }
 public CustomerService(ICustomerMapper customerMapper)
 {
     _customerMapper = customerMapper;
 }
Esempio n. 18
0
 public CustomerController(ILogger <CustomerController> logger, ICustomerBusiness customerBusiness, ICustomerMapper mapper)
 {
     _logger           = logger;
     _customerBusiness = customerBusiness;
     _mapper           = mapper;
 }
Esempio n. 19
0
 public CustomerServiceUnitTests()
 {
     _customerRepositoryStub = Substitute.For <ICustomerRepository>();
     _customerMapperStub     = Substitute.For <ICustomerMapper>();
     _customerService        = new CustomerService(_customerRepositoryStub, _customerMapperStub);
 }
Esempio n. 20
0
 public AplicCustomer(DataContext context, ICustomerValidator customerValidator, ICustomerMapper customerMapper) : base(context)
 {
     _customerValidator = customerValidator;
     _customerMapper    = customerMapper;
 }
Esempio n. 21
0
 public CustomerRepoDB(Entity.StoreDBContext context, ICustomerMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
 public CustomerController(ICustomerService customerService, ICustomerMapper mapper)
 {
     _customerService = customerService;
     _mapper          = mapper;
 }
Esempio n. 23
0
 public CustomerQuerieHandler(ICustomerRepository customerRepository, ICustomerMapper customerMapper)
 {
     _customerRepository = customerRepository;
     _customerMapper     = customerMapper;
 }
Esempio n. 24
0
        private CustomerBase EnsureCustomerExistance(ICustomerMapper mapper, int customerId)
        {
            var customer = mapper.Get(customerId);

            if (customer == null)
                throw new CustomerNotFoundException(customerId);

            return customer;
        }