public void Then_The_AccountFunds_Estimation_Applys_Etimated_Funds()
        {
            //Arrange
            _moqer.GetMock <IApplicationConfiguration>().Setup(
                x => x.FeatureExpiredFunds).Returns(true);
            _moqer.GetMock <IDateTimeService>()
            .Setup(x => x.GetCurrentDateTime()).Returns(new DateTime(DateTime.Now.Year, 1, 1));
            var estimationProjection = new AccountEstimationProjection(
                _moqer.Resolve <Account>(),
                _moqer.Resolve <AccountEstimationProjectionCommitments>(),
                _moqer.Resolve <IDateTimeService>(),
                false);

            var expiredFunds = new Dictionary <CalendarPeriod, decimal>()
            {
                { new CalendarPeriod(DateTime.Now.Year, 2), 100m }
            };

            //Act
            estimationProjection.BuildProjections();

            estimationProjection.ApplyExpiredFunds(expiredFunds);


            //Assert
            var actual = estimationProjection.Projections.FirstOrDefault(c => c.Year == DateTime.Now.Year && c.Month == 2);

            Assert.IsNotNull(actual);
            Assert.AreEqual(expiredFunds.FirstOrDefault().Value, actual.AllModelledCosts.ExpiredFunds);
        }
        public void Then_Transfer_Funds_In_Are_Reflected_In_My_Balance()
        {
            //Arrange
            _accountProjection = new List <AccountProjectionModel>
            {
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 1,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 10,
                    TransferInCostOfTraining      = 10,
                    TransferOutCompletionPayments = 0,
                    LevyFundedCompletionPayments  = 50,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 500,
                    FutureFundsNoExpiry = 550,
                },
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 2,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 10,
                    TransferInCostOfTraining      = 10,
                    TransferOutCompletionPayments = 0,
                    LevyFundedCompletionPayments  = 0,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 540,
                    FutureFundsNoExpiry = 590
                }
            };
            _moqer.GetMock <IApplicationConfiguration>().Setup(
                x => x.FeatureExpiredFunds).Returns(true);
            _moqer.GetMock <IDateTimeService>()
            .Setup(x => x.GetCurrentDateTime()).Returns(new DateTime(DateTime.Now.Year, 1, 1));
            var employerCommitments = new EmployerCommitments(EmployerAccountId, _commitments);
            var accountEstimationProjectionCommitments =
                new AccountEstimationProjectionCommitments(employerCommitments, _accountProjection.AsReadOnly());

            _moqer.SetInstance(accountEstimationProjectionCommitments);
            _estimationProjection = new AccountEstimationProjection(_moqer.Resolve <Account>(),
                                                                    _moqer.Resolve <AccountEstimationProjectionCommitments>(),
                                                                    _moqer.Resolve <IDateTimeService>(),
                                                                    false);

            //Act
            _estimationProjection.BuildProjections();

            //Assert
            var actual = _estimationProjection.Projections.OrderBy(c => c.Year).ThenBy(c => c.Month).Skip(1).FirstOrDefault();

            Assert.IsNotNull(actual);
            Assert.AreEqual(400, actual.EstimatedProjectionBalance);
        }
        public void Then_The_AccountFunds_Estimation_Uses_The_Projected_Balance_With_No_Expiry_If_Expired_Funds_Is_Disabled()
        {
            //Arrange
            _moqer.GetMock <IDateTimeService>()
            .Setup(x => x.GetCurrentDateTime()).Returns(new DateTime(DateTime.Now.Year, 1, 1));
            _estimationProjection = new AccountEstimationProjection(_moqer.Resolve <Account>(), _moqer.Resolve <AccountEstimationProjectionCommitments>(), _moqer.Resolve <IDateTimeService>(), false);

            //Act
            _estimationProjection.BuildProjections();

            //Assert
            var actual = _estimationProjection.Projections.OrderBy(c => c.Year).ThenBy(c => c.Month).FirstOrDefault();

            Assert.IsNotNull(actual);
            Assert.AreEqual(_accountProjection.First().FutureFundsNoExpiry, actual.EstimatedProjectionBalance);
        }
        public void First_Month_Is_Current_Month()
        {
            //Arrange
            _moqer.SetInstance <IDateTimeService>(new DateTimeService());
            _estimationProjection = new AccountEstimationProjection(
                _moqer.Resolve <Account>(),
                _moqer.Resolve <AccountEstimationProjectionCommitments>(),
                _moqer.Resolve <IDateTimeService>(),
                false);

            //Act
            _estimationProjection.BuildProjections();
            var projection = _estimationProjection.Projections.FirstOrDefault();

            //Assert
            Assert.IsNotNull(projection);
            Assert.IsTrue(projection.Month == DateTime.Now.Month && projection.Year == DateTime.Now.Year);
        }
        public void Then_The_Estimation_Only_Includes_Modelled_Transfer_Estimates_And_Not_Projection_Estimates()
        {
            //Arrange
            var commitments = new EmployerCommitmentsModel
            {
                SendingEmployerTransferCommitments =
                {
                    new CommitmentModel
                    {
                        CompletionAmount     = 100,
                        EmployerAccountId    = EmployerAccountId,
                        MonthlyInstallment   = 50,
                        PlannedEndDate       = new DateTime(DateTime.Now.Year, 5, 1),
                        StartDate            = new DateTime(DateTime.Now.Year, 1, 1),
                        NumberOfInstallments = 5,
                        FundingSource        = Models.Payments.FundingSource.Levy
                    }
                }
            };
            var employerCommitments = new EmployerCommitments(EmployerAccountId, commitments);
            var accountEstimationProjectionCommitments =
                new AccountEstimationProjectionCommitments(employerCommitments, _accountProjection.AsReadOnly());

            _moqer.SetInstance(accountEstimationProjectionCommitments);
            _estimationProjection = new AccountEstimationProjection(_moqer.Resolve <Account>(),
                                                                    _moqer.Resolve <AccountEstimationProjectionCommitments>(),
                                                                    _moqer.Resolve <IDateTimeService>(),
                                                                    false);

            //Act
            _estimationProjection.BuildProjections();

            //Assert
            var actual = _estimationProjection.Projections.OrderBy(c => c.Year).ThenBy(c => c.Month).FirstOrDefault();

            Assert.IsNotNull(actual);
            Assert.AreEqual(9990, actual.AvailableTransferFundsBalance);
        }
        public void SetUp()
        {
            _moqer       = new AutoMoqer();
            _commitments = new EmployerCommitmentsModel
            {
                SendingEmployerTransferCommitments =
                {
                    new CommitmentModel
                    {
                        CompletionAmount     = 100,
                        EmployerAccountId    = EmployerAccountId,
                        MonthlyInstallment   = 50,
                        PlannedEndDate       = new DateTime(DateTime.Now.Year, 5, 1),
                        StartDate            = new DateTime(DateTime.Now.Year, 1, 1),
                        NumberOfInstallments = 5,
                        FundingSource        = Models.Payments.FundingSource.Levy
                    },
                    new CommitmentModel
                    {
                        CompletionAmount     = 100,
                        EmployerAccountId    = EmployerAccountId,
                        MonthlyInstallment   = 50,
                        PlannedEndDate       = new DateTime(DateTime.Now.Year + 1, 9, 1),
                        StartDate            = new DateTime(DateTime.Now.Year + 1, 3, 1),
                        NumberOfInstallments = 5,
                        FundingSource        = Models.Payments.FundingSource.Levy
                    },
                    new CommitmentModel
                    {
                        CompletionAmount     = 100,
                        EmployerAccountId    = EmployerAccountId,
                        MonthlyInstallment   = 50,
                        PlannedEndDate       = new DateTime(DateTime.Now.Year, 5, 1),
                        StartDate            = new DateTime(DateTime.Now.Year, 1, 1),
                        NumberOfInstallments = 5,
                        FundingSource        = Models.Payments.FundingSource.Transfer
                    },
                }
            };
            var employerCommitments = new EmployerCommitments(EmployerAccountId, _commitments);

            _accountProjection = new List <AccountProjectionModel>
            {
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 1,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 10,
                    TransferOutCompletionPayments = 0,
                    LevyFundedCompletionPayments  = 50,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 500,
                    FutureFundsNoExpiry = 100
                },
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 2,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 10,
                    TransferOutCompletionPayments = 0,
                    LevyFundedCompletionPayments  = 0,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 540,
                    FutureFundsNoExpiry = 140
                },
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 3,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 10,
                    TransferOutCompletionPayments = 0,
                    LevyFundedCompletionPayments  = 0,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 580,
                    FutureFundsNoExpiry = 180
                },
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 4,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 10,
                    TransferOutCompletionPayments = 0,
                    LevyFundedCompletionPayments  = 0,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 620,
                    FutureFundsNoExpiry = 220
                },
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 5,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 10,
                    TransferOutCompletionPayments = 0,
                    LevyFundedCompletionPayments  = 0,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 660,
                    FutureFundsNoExpiry = 260
                },
                new AccountProjectionModel
                {
                    EmployerAccountId = 54321,
                    Month             = 6,
                    Year        = DateTime.Now.Year,
                    LevyFundsIn = 100,
                    TransferOutCostOfTraining     = 0,
                    TransferOutCompletionPayments = 20,
                    LevyFundedCompletionPayments  = 0,
                    LevyFundedCostOfTraining      = 50,
                    FutureFunds         = 690,
                    FutureFundsNoExpiry = 290
                }
            };

            var accountEstimationProjectionCommitments =
                new AccountEstimationProjectionCommitments(employerCommitments, _accountProjection.AsReadOnly());

            _moqer.GetMock <IDateTimeService>()
            .Setup(x => x.GetCurrentDateTime()).Returns(new DateTime(DateTime.Now.Year, 2, 1));

            _moqer.SetInstance(accountEstimationProjectionCommitments);

            _account = new Account(EmployerAccountId, 10000, 0, TransferAllowance, 10000);
            _moqer.SetInstance(_account);

            _estimationProjection = new AccountEstimationProjection(_moqer.Resolve <Account>(), _moqer.Resolve <AccountEstimationProjectionCommitments>(), _moqer.Resolve <IDateTimeService>(), false);
        }