Esempio n. 1
0
        public void GetAllShouldObtainSeveralTransactions()
        {
            var tasks          = new List <Task>();
            var merchantId     = 1;
            var supplierId     = "1";
            var transactionsNr = 10;

            var sut = new Services.PaymentRepository();

            for (var i = 0; i < transactionsNr; i++)
            {
                var expectedTransaction = new TransactionPayment()
                {
                    TransactionId = i,
                    Payment       = new TransactionPaymentDetails()
                    {
                        SupplierId = supplierId
                    }
                };

                tasks.Add(sut.Insert(expectedTransaction, merchantId));
            }

            Task.WaitAll(tasks.ToArray());

            var transactions = sut.GetAllByMerchantId(merchantId).Result;

            Assert.NotNull(transactions);
            Assert.Equal(transactionsNr, transactions.Count());
        }
Esempio n. 2
0
        public void GetAllShouldReturnTransactionsFromExpectedMerchant()
        {
            var tasks          = new List <Task>();
            var transactionsNr = 10;

            var sut = new Services.PaymentRepository();

            for (var i = 0; i < transactionsNr; i++)
            {
                var expectedTransaction = new TransactionPayment()
                {
                    TransactionId = i,
                    Payment       = new TransactionPaymentDetails()
                };

                tasks.Add(sut.Insert(expectedTransaction, (i % 2) + 1));
            }

            Task.WaitAll(tasks.ToArray());

            var transactions = sut.GetAllByMerchantId(1).Result;

            Assert.NotNull(transactions);
            Assert.Equal(transactionsNr / 2, transactions.Count());
            foreach (var transaction in transactions)
            {
                Assert.NotNull(transaction.Payment);
            }
        }