public TransactionService(IUnitOfWork unitOfWork, ITransactionDataProvider transactionDataProvider,
                           ICurrencyNormalizer normalizer, ILogger <TransactionService> logger)
 {
     _unitOfWork = unitOfWork;
     _transactionDataProvider = transactionDataProvider;
     _normalizer = normalizer;
     _logger     = logger;
 }
        public TransactionServiceTests()
        {
            _x10CadTransaction = new Transaction {
                ID = "4", Currency = KnownCurrencies.CAD, Amount = 23m, Sku = "AX10"
            };
            var x10UsdTransactionDto = new TransactionDto {
                ID = "1", Currency = KnownCurrencies.USD, Amount = 23.5m, Sku = "AX10"
            };

            var uowMock = new Mock <IUnitOfWork>();

            uowMock.Setup(x => x.TransactionRepository.GetAll())
            .Returns(new List <Transaction>
            {
                new Transaction {
                    ID = "1", Currency = KnownCurrencies.USD, Amount = 23.5m, Sku = "AX10"
                },
                new Transaction {
                    ID = "2", Currency = KnownCurrencies.UYU, Amount = 44.00m, Sku = "AX90"
                },
                new Transaction {
                    ID = "3", Currency = KnownCurrencies.CAD, Amount = 10.5m, Sku = "AX15"
                },
                _x10CadTransaction
            }.AsQueryable());

            var transactionDataProvider = new Mock <ITransactionDataProvider>();

            transactionDataProvider.Setup(x => x.GetTransactions())
            .Returns(Task.Run(() => new List <Transaction>
            {
                new Transaction {
                    Currency = KnownCurrencies.USD, Sku = "J385X", Amount = 18m
                },
                new Transaction {
                    Currency = KnownCurrencies.CAD, Sku = "J385Y", Amount = 44.5m
                }
            }));

            var failingTransactionDataProvider = new Mock <ITransactionDataProvider>();

            failingTransactionDataProvider.Setup(x => x.GetTransactions())
            .Returns(Task.Run(() =>
            {
                throw new GNBException("some fake message", ErrorCode.UnableToRetrieveTransactionsFromQuietStone);
                return(new List <Transaction>());
            }));

            var normalizer = new Mock <ICurrencyNormalizer>();

            normalizer.Setup(x => x.Normalize(KnownCurrencies.USD, It.IsAny <IEnumerable <TransactionDto> >()))
            .Returns(Task.Run(() =>
                              new List <TransactionDto>
            {
                new TransactionDto
                {
                    ID       = _x10CadTransaction.ID,
                    Currency = KnownCurrencies.USD,
                    Sku      = _x10CadTransaction.Sku,
                    Amount   = _x10CadTransaction.Amount * CadToUsdRate
                },
                x10UsdTransactionDto
            }.AsEnumerable()));

            _unitOfWork = uowMock.Object;
            _normalizer = normalizer.Object;
            _failingTransactionDataProvider = failingTransactionDataProvider.Object;
            _transactionDataProvider        = transactionDataProvider.Object;
            _logger = new Mock <ILogger <TransactionService> >().Object;

            MapsterConfig.Configure();
        }