public void ThenTheCompletionPaymentsShouldNotBeIncludedInTheProjection()
 {
     Commitments.GroupBy(commitment => commitment.PlannedEndDate.AddMonths(1))
     .Select(g => new { Date = g.Key, CompletionAmount = g.Sum(commitment => commitment.CompletionAmount) })
     .ToList()
     .ForEach(completionAmount => Assert.IsFalse(AccountProjections.Any(ac => ac.Year == completionAmount.Date.Year && ac.Month == completionAmount.Date.Month && ac.LevyFundedCompletionPayments == completionAmount.CompletionAmount), $"Completion amount not found. Date: {completionAmount.Date:MMMM yyyy}, Completion Amount: {completionAmount}"));
 }
Example #2
0
        public void ThenTheCo_InvestmentAmountIsZero()
        {
            var projection = AccountProjections
                             .OrderBy(m => m.Year)
                             .ThenBy(m => m.Month)
                             .First();

            Assert.AreEqual(0, projection.CoInvestmentEmployer + projection.CoInvestmentGovernment);
        }
Example #3
0
        public void ThenTheBalanceShouldBe(int p0)
        {
            var projection = AccountProjections
                             .OrderBy(m => m.Year)
                             .ThenBy(m => m.Month)
                             .First();

            projection.FutureFunds.Should().Be(p0);
        }
        public AccountManagerViewModel()
        {
            _accountProjections =
                new ObservableCollection <AccountProjectionViewModel>()
            {
                new AccountProjectionViewModel()
                {
                    Login      = "******",
                    ServerName = "+"
                }
            };

            _container       = ContainerConfiguration.GetContainer().Container;
            _accountRegistry = _container.Resolve <UnityDisk.Accounts.Registry.IAccountRegistry>();

            _accountRegistry.ChangedSizeEvent += (o, e) =>
            {
                TotalSize = e.NewSize.TotalSize;
                UsedSize  = e.NewSize.TotalSize;
                FreeSize  = e.NewSize.FreeSize;

                AccountProjectionViewModel projection =
                    AccountProjections.FirstOrDefault(accountProjection => accountProjection.Login == e.Account.Login);
                if (projection == null)
                {
                    return;
                }
                projection.TotalSize = e.Account.Size.TotalSize;
                projection.UsedSize  = e.Account.Size.UsedSize;
                projection.FreeSize  = e.Account.Size.FreeSize;
            };
            _accountRegistry.LoadedEvent += (o, e) =>
            {
                foreach (var account in e.Accounts)
                {
                    AccountProjections.Add(new AccountProjectionViewModel(account));
                }
            };
            _accountRegistry.ChangedRegistryEvent += (o, e) =>
            {
                switch (e.Action)
                {
                case RegistryActionEnum.Added:
                    AccountProjections.Add(new AccountProjectionViewModel(e.Account));
                    break;

                case RegistryActionEnum.Removed:
                    AccountProjections.Remove(AccountProjections.First(model => model.Login == e.Account.Login));
                    break;

                case RegistryActionEnum.Reseted:
                    AccountProjections.Clear();
                    break;
                }
            };
        }
 public void ThenTheTrainingCostsShouldBeIncludedInTheCorrectMonth()
 {
     AccountProjections.ForEach(projection =>
     {
         var expectedCost = Commitments
                            .Where(c => IsIncluded(c, projection.Month, projection.Year))
                            .Sum(c => c.InstallmentAmount);
         Assert.AreEqual(expectedCost, projection.LevyFundedCostOfTraining,
                         $"Total cost of training mismatch. Month: {projection.Month}, Year: {projection.Year}, Expected amount: {expectedCost} but was: {projection.LevyFundedCostOfTraining}");
     });
 }
        public void ThenTheTransferCompletionPaymentsShouldBeRecordedAsFollows(Table table)
        {
            var expectedProjections = table.CreateSet <TestAccountProjection>().ToList();

            expectedProjections.ForEach(expected =>
            {
                var projectionMonth = AccountProjections.Skip(expected.MonthsFromNow).FirstOrDefault();
                Assert.IsNotNull(projectionMonth, $"Month {expected.MonthsFromNow} not found.");
                Assert.AreEqual(expected.TransferInCompletionPayments, projectionMonth.TransferInCompletionPayments, $"Transfer in completion payments do not match.  Months from now: {expected.MonthsFromNow}, expected '{expected.TransferInCompletionPayments}' but generated amount was '{projectionMonth.TransferInCompletionPayments}'");
                Assert.AreEqual(expected.TransferOutCompletionPayments, projectionMonth.TransferOutCompletionPayments, $"Transfer out completion payments do not match.  Months from now: {expected.MonthsFromNow}, expected '{expected.TransferOutCompletionPayments}' but generated amount was '{projectionMonth.TransferOutCompletionPayments}'");
            });
        }
Example #7
0
        public void ThenTheGovernmentCo_InvestmentAmountIsOfTheNegativeValue()
        {
            var projection = AccountProjections
                             .OrderBy(m => m.Year)
                             .ThenBy(m => m.Month)
                             .First();
            var currentBalance = Convert.ToDecimal(ScenarioContext.Current["current_balance"]);

            if (currentBalance < 0)
            {
                currentBalance = 0;
            }

            var coInvestmentAmount = projection.CoInvestmentGovernment;
            var costOfTraining     = projection.LevyFundedCostOfTraining - currentBalance;

            Assert.AreEqual(0.9m, coInvestmentAmount / costOfTraining);
        }
        public void ThenShouldHaveFollowingProjections(Table table)
        {
            var expectedProjections = table.CreateSet <TestAccountProjection>().ToList();

            foreach (var p in expectedProjections)
            {
                var date       = DateTime.Today.AddMonths(p.MonthsFromNow);
                var projection = AccountProjections.Single(m => m.Month == date.Month && m.Year == date.Year);
                if (table.ContainsColumn("Transfer In Total Cost Of Training"))
                {
                    projection.TransferInCostOfTraining.Should().Be(p.TransferInTotalCostOfTraining);
                }
                if (table.ContainsColumn("Transfer Out Total Cost Of Training"))
                {
                    projection.TransferOutCostOfTraining.Should().Be(p.TransferOutTotalCostOfTraining);
                }
            }
        }
        public void ThenShouldHaveFollowingProjectionsFromCompletion(Table table)
        {
            var expectedProjections = table.CreateSet <TestAccountProjection>().ToList();

            foreach (var p in expectedProjections)
            {
                var date       = DateTime.Today.AddMonths(p.MonthsFromNow);
                var projection = AccountProjections.Single(m => m.Month == date.Month && m.Year == date.Year);

                string becauseMessage(string propName, object expected, object actual)
                {
                    return($"Date: {date.Month}-{date.Year}, " +
                           $"Expected {propName} to be {expected} but was {actual}.");
                };

                projection.LevyFundedCostOfTraining.Should().Be(p.TotalCostOfTraining,
                                                                becauseMessage(nameof(p.TotalCostOfTraining), p.TotalCostOfTraining, projection.LevyFundedCostOfTraining));

                projection.TransferInCostOfTraining.Should().Be(p.TransferInTotalCostOfTraining,
                                                                becauseMessage(nameof(p.TransferInTotalCostOfTraining), p.TransferInTotalCostOfTraining, projection.TransferInCostOfTraining));

                projection.TransferOutCostOfTraining.Should().Be(p.TransferOutTotalCostOfTraining,
                                                                 becauseMessage(nameof(p.TransferOutTotalCostOfTraining), p.TransferOutTotalCostOfTraining, projection.TransferOutCostOfTraining));

                projection.LevyFundedCompletionPayments.Should().Be(p.CompletionPayments,
                                                                    becauseMessage(nameof(p.CompletionPayments), p.CompletionPayments, projection.LevyFundedCompletionPayments));

                projection.TransferInCompletionPayments.Should().Be(p.TransferInCompletionPayments,
                                                                    becauseMessage(nameof(p.TransferInCompletionPayments), p.TransferInCompletionPayments, projection.TransferInCompletionPayments));

                projection.TransferOutCompletionPayments.Should().Be(p.TransferOutCompletionPayments,
                                                                     becauseMessage(nameof(p.TransferOutCompletionPayments), p.TransferOutCompletionPayments, projection.TransferOutCompletionPayments));

                projection.FutureFunds.Should().Be(p.FutureFunds,
                                                   becauseMessage(nameof(p.FutureFunds), p.FutureFunds, projection.FutureFunds));

                projection.ExpiredFunds.Should().Be(p.ExpiredFunds,
                                                    becauseMessage(nameof(p.ExpiredFunds), p.ExpiredFunds, projection.ExpiredFunds));
            }
        }
 public void ThenTheTotalCompletionAmountIs(int amount)
 {
     Assert.AreEqual(amount, AccountProjections.Sum(c => c.LevyFundedCompletionPayments));
 }
 public void ThenTheFirstMonthShouldBeThisMonthRatherThanNextMonth()
 {
     Assert.AreEqual(AccountProjections.First().Month, ProjectionsStartPeriod.Month, $"Expected the first month to be {ProjectionsStartPeriod.Month} but was {AccountProjections.First().Month}");
 }
        public void ThenEachFutureMonthSForecastLevyCreditShouldBeTheSame()
        {
            var fundsIn = LevySubmissions.Sum(levy => levy.Amount);

            Assert.IsTrue(AccountProjections.All(projection => projection.LevyFundsIn == fundsIn));
        }
 public void ThenCalculatedLevyCreditValueShouldBeTheAmountDeclaredForTheSumOfTheLinkedPAYESchemes()
 {
     AccountProjections.ForEach(projection => Assert.AreEqual(projection.LevyFundsIn, LevySubmissions.Sum(levy => levy.Amount), $"Expected the account projections to be {LevySubmissions.FirstOrDefault()?.Amount} but was {projection.LevyFundsIn}"));
 }