public async Task DetailsTest()
        {
            Guid   id        = Guid.NewGuid();
            string lowellRef = "12345678";

            Account account = new Account()
            {
                AccountReference   = "12345678",
                OutstandingBalance = 999.99M,
            };

            MyAccountsDetailVm vm = new MyAccountsDetailVm()
            {
                AccountReferenceText   = "12345678",
                OutstandingBalanceText = "£999.99"
            };

            this._sessionState.Setup(x => x.GetLowellReferenceFromSurrogate(id)).Returns("12345678");
            this._accountsService.Setup(x => x.GetAccount(this._caseflowUserId, lowellRef)).Returns(Task.FromResult(account));
            this._mapper.Setup(x => x.Map <Account, MyAccountsDetailVm>(account)).Returns(vm);
            this._gtmService.Setup(x => x.RaiseAccountDetailsViewedEvent(vm, this._caseflowUserId, "Regular Account")).Verifiable();
            this._webActivityService.Setup(x => x.LogAccountDetailsViewed("12345678", this._caseflowUserId)).Returns(Task.CompletedTask);
            this._sessionState.Setup(x => x.GetLoggedInLowellRef()).Returns("12345678");

            ViewResult result = (ViewResult)await this._controller.Details(id);

            this._gtmService.Verify(x => x.RaiseAccountDetailsViewedEvent(vm, this._caseflowUserId, "Regular Account"), Times.Once);
            this.VerifyAll();

            Assert.AreSame(vm, result.Model);
            Assert.AreEqual(this._caseflowUserId, ((MyAccountsDetailVm)result.Model).LoggedInUserId);
            Assert.AreEqual("12345678", ((MyAccountsDetailVm)result.Model).LoggedInLowellRef);
            Assert.AreEqual(id, ((MyAccountsDetailVm)result.Model).LowellReferenceSurrogateKey);
        }
예제 #2
0
        public void ConvertTest_SourceNull()
        {
            Account            source      = null;
            MyAccountsDetailVm destination = new MyAccountsDetailVm();
            MyAccountsDetailVm expected    = null;

            MyAccountsDetailVm result = _converter.Convert(source, destination, null);

            Assert.AreEqual(expected, result);
        }
예제 #3
0
        public async Task <IActionResult> Details(Guid id)
        {
            string lowellReference = ApplicationSessionState.GetLowellReferenceFromSurrogate(id);

            Account account = await _accountsService.GetAccount(LoggedInUserId, lowellReference);

            MyAccountsDetailVm vm = _mapper.Map <Account, MyAccountsDetailVm>(account);

            vm.LoggedInUserId              = LoggedInUserId;
            vm.LoggedInLowellRef           = ApplicationSessionState.GetLoggedInLowellRef();
            vm.LowellReferenceSurrogateKey = id;

            _gtmService.RaiseAccountDetailsViewedEvent(vm, LoggedInUserId, "Regular Account");
            await _webActivityService.LogAccountDetailsViewed(vm.AccountReferenceText, LoggedInUserId);

            return(View(vm));
        }
예제 #4
0
        public void ConvertTest()
        {
            Account source = new Account()
            {
                AccountMessage                = "AccountMessage",
                AccountReference              = "AccountReference",
                AccountStatus                 = "AccountStatus",
                AccountStatusIsClosed         = false,
                AccountStatusIsViewOnly       = false,
                AccountStatusIsWithSolicitors = false,
                AccountStatusSort             = 1,
                AddedSinceLastLogin           = true,
                CanAmendPlan             = true,
                CanMakePayment           = true,
                CanManageAccount         = true,
                ClientReference          = "ClientReference",
                DirectDebitInFlight      = false,
                DiscountedBalance        = 111.11M,
                DiscountOfferAmount      = 222.22M,
                DiscountOfferExpiry      = DateTime.Now.AddDays(30),
                HasArrangement           = true,
                NeverAllowPlanTransfer   = false,
                NextPlanPaymentDate      = DateTime.Now.AddDays(7),
                OriginalCompany          = "OriginalCompany",
                OutstandingBalance       = 555.55M,
                PaymentPlanAmount        = 50,
                PaymentPlanArrearsAmount = 100,
                PaymentPlanFrequency     = "monthly",
                PaymentPlanIsAutomated   = true,
                PaymentPlanMethod        = "direct debit",
                PlanPendingTransfer      = false,
                PlanTransferredFrom      = "PlanTransferredFrom",
                PlanMessages             = new string[] { "Plan Message 1", "Plan Message 2" },
                RecentTransactions       = new List <Transaction>()
                {
                    new Transaction()
                    {
                        Amount = 23.50M, Description = "Transaction 1", Type = "credit", RollingBalance = 550.00M, Date = DateTime.Now.AddDays(-150)
                    },
                    new Transaction()
                    {
                        Amount = 60.50M, Description = "Transaction 2", Type = "credit", RollingBalance = 500.00M, Date = DateTime.Now.AddDays(-120)
                    },
                    new Transaction()
                    {
                        Amount = 34.50M, Description = "Transaction 3", Type = "credit", RollingBalance = 450.00M, Date = DateTime.Now.AddDays(-90)
                    },
                    new Transaction()
                    {
                        Amount = 67.50M, Description = "Transaction 4", Type = "credit", RollingBalance = 400.00M, Date = DateTime.Now.AddDays(-60)
                    },
                    new Transaction()
                    {
                        Amount = 54.50M, Description = "Transaction 5", Type = "credit", RollingBalance = 350.00M, Date = DateTime.Now.AddDays(-30)
                    },
                }
            };

            MyAccountsDetailVm destination = new MyAccountsDetailVm();

            MyAccountsDetailVm expected = new MyAccountsDetailVm()
            {
                PlanDescription = "PlanDescription",
                DiscountAvailableLinkTextOptional = "DiscountAvailableLinkTextOptional",
                AccountMessage     = "AccountMessage",
                ArrearsMessage     = "ArrearsMessage",
                RecentTransactions = new List <TransactionVm>()
                {
                    new TransactionVm()
                    {
                        AmountText = "£23.50", Description = "Transaction 1", RollingBalanceText = "£550.00", DateText = DateTime.Now.AddDays(-150).ToString("dd MMM y", CultureInfo.CurrentCulture)
                    },
                    new TransactionVm()
                    {
                        AmountText = "£60.50", Description = "Transaction 1", RollingBalanceText = "£500.00", DateText = DateTime.Now.AddDays(-120).ToString("dd MMM y", CultureInfo.CurrentCulture)
                    },
                    new TransactionVm()
                    {
                        AmountText = "£34.50", Description = "Transaction 1", RollingBalanceText = "£450.00", DateText = DateTime.Now.AddDays(-90).ToString("dd MMM y", CultureInfo.CurrentCulture)
                    },
                    new TransactionVm()
                    {
                        AmountText = "£67.50", Description = "Transaction 1", RollingBalanceText = "£400.00", DateText = DateTime.Now.AddDays(-60).ToString("dd MMM y", CultureInfo.CurrentCulture)
                    },
                    new TransactionVm()
                    {
                        AmountText = "£54.50", Description = "Transaction 1", RollingBalanceText = "£350.00", DateText = DateTime.Now.AddDays(-30).ToString("dd MMM y", CultureInfo.CurrentCulture)
                    },
                },
                OriginalCompanyText           = "OriginalCompany",
                AccountReferenceText          = "AccountReference",
                OutstandingBalanceText        = "£555.55",
                AccountStatusText             = "AccountStatus",
                NextPlanPaymentDate           = source.NextPlanPaymentDate,
                ClientReference               = "ClientReference",
                AddedSinceLastLogin           = true,
                HasArrangement                = true,
                DiscountedBalanceTextOptional = "£111.11",
                IsPaymentButtonAvailable      = true,
                CanAmendPlan                = true,
                DirectDebitInFlight         = false,
                AccountWithSolicitors       = false,
                PlanMessage                 = "Plan Message 1",
                PlanPendingTransfer         = false,
                PlanTransferredFrom         = "PlanTransferredFrom",
                PlanTransferredFromAccounts = new List <string>()
                {
                    "PlanTransferredFrom"
                },
                NeverAllowPlanTransfer = false,
                PlanTransferredFromAccountsFormatted = "DerivePlanTransferredFromAccountsFormatted",
                PlanTransferOptOutNumber             = "PlanTransferOptOutNumber"
            };

            _mapperHelper.Setup(x => x.DerivePlanDescription(source)).Returns("PlanDescription");
            _mapperHelper.Setup(x => x.DeriveDiscountDescription(source)).Returns("DiscountAvailableLinkTextOptional");
            _mapperHelper.Setup(x => x.DeriveArrearsDetail(source.PaymentPlanArrearsAmount, source.PaymentPlanIsAutomated)).Returns("ArrearsMessage");
            _mapperHelper.Setup(x => x.DerivePlanTransferredFromAccountsFormatted(
                                    It.Is <List <string> >(a => a != null && a.Count == 1 && a[0] == "PlanTransferredFrom")))
            .Returns("DerivePlanTransferredFromAccountsFormatted");
            _portalSettings.SolicitorsRedirectUrl    = "SolicitorsRedirectUrl";
            _portalSettings.PlanTransferOptOutNumber = "PlanTransferOptOutNumber";

            _mapper.Setup(x => x.Map <List <Transaction>, List <TransactionVm> >(source.RecentTransactions)).Returns(expected.RecentTransactions);

            MyAccountsDetailVm result = _converter.Convert(source, destination, null);

            Assert.IsTrue(Utilities.DeepCompare(expected, result));
        }