Ejemplo n.º 1
0
 public EmailService(IDbContext context, Logger logger, ApplicationService applicationService, EmailLogService emailLogService)
 {
     _ctx = context;
     _logger = logger;
     _applicationService = applicationService;
     _emailLogService = emailLogService;
 }
Ejemplo n.º 2
0
 public EmailService(IDbContext context, Logger logger)
 {
     _ctx = context;
     _logger = logger;
     _applicationService = new ApplicationService(_ctx);
     _emailLogService = new EmailLogService(_ctx);
 }
Ejemplo n.º 3
0
 public EmailService(IDbContext context)
 {
     _ctx = context;
     _logger = LogManager.GetCurrentClassLogger();
     _applicationService = new ApplicationService(_ctx);
     _emailLogService = new EmailLogService(_ctx);
 }
Ejemplo n.º 4
0
 public SMSService(IDbContext context, Logger logger)
 {
     _ctx = context;
     _logger = logger;
     _applicationService = new ApplicationService(_ctx);
     _formattingServices = new FormattingServices();
     _smsLogService = new SMSLogService(_ctx);
 }
Ejemplo n.º 5
0
 public SMSService(IDbContext context)
 {
     _ctx = context;
     _logger = LogManager.GetCurrentClassLogger();
     _applicationService = new ApplicationService(_ctx);
     _formattingServices = new FormattingServices();
     _smsLogService = new SMSLogService(_ctx);
 }
Ejemplo n.º 6
0
 public SMSService(ApplicationService applicationService, SMSLogService smsLogService, IDbContext context
     , Logger logger)
 {
     _applicationService = applicationService;
     _formattingServices = new FormattingServices();
     _smsLogService = smsLogService;
     _ctx = context;
     _logger = logger;
 }
Ejemplo n.º 7
0
 public MessageServices(IDbContext context)
 {
     _context = context;
     _logger = LogManager.GetCurrentClassLogger();
     _validationService = new ValidationService(_logger);
     _formattingServices = new FormattingServices();
     _applicationServices = new ApplicationService(_context);
     _securityServices = new SecurityService();
     _userServices = new UserService(_context);
 }
        public void WhenBatching3TransactionsWithOpenBatchTransactionsInBatchIs3()
        {
            ApplicationService applicationService = new ApplicationService(_ctx);
            MessageServices messageService = new MessageServices(_ctx);
            UserService userService = new UserService(_ctx);
            PaymentAccountService paymentAccountService = new PaymentAccountService(_ctx);
            TransactionBatchService transactionBatchService = new TransactionBatchService(_ctx, _logger);

            var transactionBatchGuid = Guid.NewGuid();
            var transactionAmount = 2.75;

            _ctx.TransactionBatches.Add(new TransactionBatch()
            {
                CreateDate = System.DateTime.Now,
                Id = transactionBatchGuid,
                IsClosed = true,
                TotalDepositAmount = 0,
                TotalNumberOfDeposits = 0,
                TotalWithdrawalAmount = 0,
                TotalNumberOfWithdrawals = 0,
                Transactions = new List<Transaction>()
            });
            _ctx.SaveChanges();

            var application = applicationService.AddApplication("Test", "http://www.test.com", true);
            var sender = userService.AddUser(application.ApiKey, "*****@*****.**", "pdthx123",
                "*****@*****.**", "1234");
            sender.SecurityPin = "2589";
            userService.UpdateUser(sender);

            var senderPaymentAccount = paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "Sender PaidThx",
                "053000219", "1234123412", "Checking");

            sender.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            sender.PaymentAccounts.Add(senderPaymentAccount);

            var transaction1 = new Domain.Transaction()
            {
                Amount = 1,
                Category = TransactionCategory.Payment,
                FromAccount = senderPaymentAccount,
                CreateDate = System.DateTime.Now,
                Id = Guid.NewGuid(),
                PaymentChannelType = PaymentChannelType.Single,
                StandardEntryClass = StandardEntryClass.Web,
                Status = TransactionStatus.Submitted,
                Type = TransactionType.Withdrawal,
                User = sender
            };
            var transaction2 = new Domain.Transaction()
            {
                Amount = 2,
                Category = TransactionCategory.Payment,
                FromAccount = senderPaymentAccount,
                CreateDate = System.DateTime.Now,
                Id = Guid.NewGuid(),
                PaymentChannelType = PaymentChannelType.Single,
                StandardEntryClass = StandardEntryClass.Web,
                Status = TransactionStatus.Submitted,
                Type = TransactionType.Withdrawal,
                User = sender
            };
            var transaction3 = new Domain.Transaction()
            {
                Amount = 3,
                Category = TransactionCategory.Payment,
                FromAccount = senderPaymentAccount,
                CreateDate = System.DateTime.Now,
                Id = Guid.NewGuid(),
                PaymentChannelType = PaymentChannelType.Single,
                StandardEntryClass = StandardEntryClass.Web,
                Status = TransactionStatus.Submitted,
                Type = TransactionType.Deposit,
                User = sender
            };

            transactionBatchService.BatchTransactions(new List<Transaction>()
            {
                transaction1,
                transaction2,
                transaction3
            });

            var transactionBatch = transactionBatchService.GetOpenBatch();

            Assert.AreEqual(3, transactionBatch.Transactions.Count);
            Assert.AreEqual(1, transactionBatch.TotalNumberOfDeposits);
            Assert.AreEqual(2, transactionBatch.TotalNumberOfWithdrawals);
        }
        public void WhenGettingOpenBatchWithNoOpenBatchesNewBatchIsCreated()
        {
            ApplicationService applicationService = new ApplicationService(_ctx);
            MessageServices messageService = new MessageServices(_ctx);
            UserService userService = new UserService(_ctx);
            PaymentAccountService paymentAccountService = new PaymentAccountService(_ctx);
            TransactionBatchService transactionBatchService = new TransactionBatchService(_ctx, _logger);

            var transactionBatchGuid = Guid.NewGuid();

            _ctx.TransactionBatches.Add(new TransactionBatch()
            {
                CreateDate = System.DateTime.Now,
                Id = transactionBatchGuid,
                IsClosed = true,
                TotalDepositAmount = 0,
                TotalNumberOfDeposits = 0,
                TotalWithdrawalAmount = 0,
                TotalNumberOfWithdrawals = 0,
                Transactions = new List<Transaction>()
            });

            var transactionBatch = transactionBatchService.GetOpenBatch();

            Assert.AreNotEqual(transactionBatchGuid, transactionBatch.Id);
        }
        public void WhenBatchingMessageWithOpenBatchWithWithdrawAndDepositTransactionThenTransactionsInBatchIs2()
        {
            ApplicationService applicationService = new ApplicationService(_ctx);
            MessageServices messageService = new MessageServices(_ctx);
            UserService userService = new UserService(_ctx);
            PaymentAccountService paymentAccountService = new PaymentAccountService(_ctx);
            TransactionBatchService transactionBatchService = new TransactionBatchService(_ctx, _logger);

            var transactionBatchGuid = Guid.NewGuid();
            var transactionAmount = 2.75;

            _ctx.TransactionBatches.Add(new TransactionBatch()
            {
                CreateDate = System.DateTime.Now,
                Id = transactionBatchGuid,
                IsClosed = false,
                TotalDepositAmount = 0,
                TotalNumberOfDeposits = 0,
                TotalWithdrawalAmount = 0,
                TotalNumberOfWithdrawals = 0,
                Transactions = new List<Transaction>()
            });
            _ctx.SaveChanges();

            var application = applicationService.AddApplication("Test", "http://www.test.com", true);
            var sender = userService.AddUser(application.ApiKey, "*****@*****.**", "pdthx123",
                "*****@*****.**", "1234");
            sender.SecurityPin = "2589";
            userService.UpdateUser(sender);

            var senderPaymentAccount = paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "Sender PaidThx",
                "053000219", "1234123412", "Checking");

            sender.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            sender.PaymentAccounts.Add(senderPaymentAccount);

            var recipient = userService.AddUser(application.ApiKey, "*****@*****.**", "pdthx123",
                "*****@*****.**", "1234");

            var recipientPaymentAccount = paymentAccountService.AddPaymentAccount(sender.UserId.ToString(), "Recipient PaidThx",
            "053000219", "1234123412", "Savings");

            recipient.PaymentAccounts = new System.Collections.ObjectModel.Collection<PaymentAccount>();
            recipient.PaymentAccounts.Add(recipientPaymentAccount);

            var message = messageService.AddMessage(application.ApiKey.ToString(), sender.EmailAddress, recipient.EmailAddress,
                senderPaymentAccount.Id.ToString(), transactionAmount, "Test Payment", "Payment", "2589");

            message.Recipient = userService.FindUserByEmailAddress(recipient.EmailAddress);

            transactionBatchService.BatchTransactions(message);

            var transactionBatch = transactionBatchService.GetOpenBatch();

            Assert.AreEqual(transactionBatchGuid, transactionBatch.Id);
            Assert.AreEqual(2, transactionBatch.Transactions.Count);
            Assert.AreEqual(1, transactionBatch.TotalNumberOfDeposits);
            Assert.AreEqual(1, transactionBatch.TotalNumberOfWithdrawals);
        }