Exemple #1
0
 public DiscountCuponDomainService(
     IMediatorHandler bus,
     IDiscountCuponReaderRepository repostory) : base()
 {
     _repostory = repostory;
     _bus       = bus;
 }
        public CommandsTest()
        {
            // repositories
            var productRepository      = new ProductFakeRepository();
            var customerRepository     = new CustomerFakeRepository();
            var cuponDisountRepository = new DiscountCuponFakeReaderRepository();

            _products          = productRepository.Take(10);
            _customer          = customerRepository.GetByDocument(new Document("94763001086"));
            _creditCardCommand = new CreditCardCommand()
            {
                Cvv       = 503,
                Number    = "5361004355915434",
                PrintName = "Nicolas S. dos Santos",
                Validate  = "16/06/2020",
            };

            var orderRepository = new OrderFakeRepository(customerRepository.GetAll(), _products);

            // mock order
            _order = orderRepository.GetFirst();

            // dependencies
            var notifications = new DomainNotificationHandler();
            var uow           = new UnitOfWorkFake();
            var bus           = new MediatorHandlerFake(notifications);

            // tests global dependencies
            _customerRepository     = customerRepository;
            _productRepository      = productRepository;
            _orderRepository        = orderRepository;
            _cuponDisountRepository = cuponDisountRepository;

            // domain services
            var discountCuponDomainService = new DiscountCuponDomainService(bus, _cuponDisountRepository);

            _commandHanddler = new OrderCommandHandler(
                discountCuponDomainService,
                _orderRepository,
                _productRepository,
                _customerRepository,
                uow,
                bus,
                notifications);
        }