public void ShouldScheduleEmailsOnAccountToAccountTransfer()
        {
            // arrange
            var handler        = (SyncBalanceChangedMessageHandler)NotificationServer.Container.Resolve <IHandler <BalanceChangedMessage> >();
            var database       = WebApiServer.Container.Resolve <IDatabaseContext>();
            var accountService = WebApiServer.Container.Resolve <IAccountService>();

            var customer = new Individual("testuser123", "*****@*****.**", "alksdjfas", "Test", "Test");
            var account1 = customer.AddAccount("9999999999999991", "USD");
            var account2 = customer.AddAccount("9999999999999992", "EUR");

            account1.Balance = 100;
            account2.Balance = 0;
            database.Customers.Insert(customer);

            try
            {
                // act
                accountService.TransferMoney(account1, account2, 50, AmountConversionMode.SourceToTarget, "Email Notification Integration Test");
                handler.SyncRoot.WaitOne(TestVars.DefaultTimeout);

                // assert
                account1.Balance.ShouldBe(50);
                account2.Balance.ShouldBeGreaterThan(0);

                var emails = database.ScheduledEmails.FindByRecipientAddress(customer.Email).ToList();

                emails.ShouldContain(x => x.Subject == "Balance of your account has changed" &&
                                     x.Body.Contains(account1.AccountNumber) &&
                                     x.Body.Contains($"Total outcome is 50 USD"));

                emails.ShouldContain(x => x.Subject == "Balance of your account has changed" &&
                                     x.Body.Contains(account2.AccountNumber) &&
                                     x.Body.Contains($"Total income is {account2.Balance} EUR"));
            }
            finally
            {
                database.Customers.Delete(customer);
            }
        }
Exemple #2
0
        public void TestIndividualWithAccount()
        {
            // arrange
            var individual = new Individual("testuser", "*****@*****.**", "hash", "Evgeny", "Shamenv");
            var loginInfo  = new LoginInfo("testprovider", "testkey");

            individual.AddLogin(loginInfo);

            var account = individual.AddAccount("1234567890", "USD");

            account.BankCard = new BankCard("123", "0000", "EVGENY SHMANEV", "1234567890", 12, 2099);

            // act
            var result = (Individual)RunTest(individual, _databaseContext.Customers, x => x.Id);

            // assert
            result.UserName.ShouldBe(individual.UserName);
            result.Email.ShouldBe(individual.Email);
            result.PasswordHash.ShouldBe(individual.PasswordHash);
            result.FirstName.ShouldBe(individual.FirstName);
            result.LastName.ShouldBe(individual.LastName);

            result.Logins.Count().ShouldBe(1);
            result.Logins.First().LoginKey.ShouldBe(loginInfo.LoginKey);
            result.Logins.First().ProviderName.ShouldBe(loginInfo.ProviderName);

            result.Accounts.Count().ShouldBe(1);
            result.Accounts.First().AccountNumber.ShouldBe(account.AccountNumber);
            result.Accounts.First().Currency.ShouldBe(account.Currency);

            result.Accounts.First().BankCard.CardHolder.ShouldBe(account.BankCard.CardHolder);
            result.Accounts.First().BankCard.CardNumber.ShouldBe(account.BankCard.CardNumber);
            result.Accounts.First().BankCard.CsvCode.ShouldBe(account.BankCard.CsvCode);
            result.Accounts.First().BankCard.ExpirationMonth.ShouldBe(account.BankCard.ExpirationMonth);
            result.Accounts.First().BankCard.ExpirationYear.ShouldBe(account.BankCard.ExpirationYear);
            result.Accounts.First().BankCard.PinCode.ShouldBe(account.BankCard.PinCode);
        }
        public void ShouldRedirectToStoreAfterPayment(string merchantId, string currency, string cardHolderName, string cardNumber, string securityCode, int monthExpired, int yearExpired, string expectedError)
        {
            // arrange
            var model = new OnlinePaymentViewModel
            {
                MerchantId     = new Guid(merchantId),
                Amount         = 1000,
                Currency       = currency,
                RedirectUrl    = "http://test.com",
                CardHolderName = cardHolderName,
                CardNumber     = cardNumber,
                SecurityCode   = securityCode,
                MonthExpired   = monthExpired,
                YearExpired    = yearExpired
            };

            var customer        = new Individual("customer", "test@com", "pass", "Evgeny", "Shmanev");
            var customerAccount = customer.AddAccount("11111111", "EUR");

            customerAccount.BankCard = new BankCard("123", "0000", "EVGENY SHMANEV", "12345", 1, 2020);
            _bankCardService.Setup(x => x.FindBankCard("12345")).Returns(customerAccount.BankCard);

            var merchant        = new Merchant("merchant", "test@com", "pass", new Guid("E5310F8F-117B-4D60-8239-39A42A94ADC9"), "store", "contact");
            var merchantAccount = merchant.AddAccount("222222222", "USD");

            _merchantService.Setup(x => x.FindMerchant(merchant.MerchantId)).Returns(merchant);

            // act
            var result = _controller.Payment(model).Result;

            // assert
            _controller.ModelState.IsValid.ShouldBeTrue();
            _accountService.Verify(x => x.TransferMoney(customerAccount, merchantAccount, model.Amount, AmountConversionMode.TargetToSource, $"Online payment on {merchant.MerchantName}."));
            result.ShouldBeOfType <RedirectResult>()
            .Url.ShouldBe("http://test.com?status=success");
        }