Example #1
0
        public async Task ApplyCalculationAsync_WhenCalled_ReturnsSamePostingLine()
        {
            IPostingLine sut = CreateSut();

            IPostingLine result = await sut.ApplyCalculationAsync(_fixture.BuildAccountMock().Object);

            Assert.That(result, Is.SameAs(sut));
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasNotGiven_ReturnsSamePostingLineWhereBudgetAccountValuesAtPostingDateNotEqualToNull()
        {
            IPostingLine sut = CreateSut();

            IPostingLine result = await sut.ApplyCalculationAsync(_fixture.BuildBudgetAccountMock().Object);

            Assert.That(result.BudgetAccountValuesAtPostingDate, Is.Not.Null);
        }
        public async Task ApplyCalculationAsync_WhenCalled_ReturnsSamePostingLineWhereBudgetAccountIsNotNull()
        {
            IPostingLine sut = CreateSut();

            IPostingLine result = await sut.ApplyCalculationAsync(_fixture.BuildBudgetAccountMock().Object);

            Assert.That(result.BudgetAccount, Is.Not.Null);
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasNotGiven_AssertPostingLineCollectionWasCalledOnCalculatedBudgetAccount()
        {
            IPostingLine sut = CreateSut();

            Mock <IBudgetAccount> calculatedBudgetAccountMock = _fixture.BuildBudgetAccountMock();
            await sut.ApplyCalculationAsync(calculatedBudgetAccountMock.Object);

            calculatedBudgetAccountMock.Verify(m => m.PostingLineCollection, Times.Once);
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasGiven_ReturnsSamePostingLineWhereBudgetAccountValuesAtPostingDateEqualToBudgetAccountValuesAtPostingDate()
        {
            IBudgetInfoValues budgetAccountValuesAtPostingDate = _fixture.BuildBudgetInfoValuesMock().Object;
            IPostingLine      sut = CreateSut(budgetAccountValuesAtPostingDate: budgetAccountValuesAtPostingDate);

            IPostingLine result = await sut.ApplyCalculationAsync(_fixture.BuildBudgetAccountMock().Object);

            Assert.That(result.BudgetAccountValuesAtPostingDate, Is.EqualTo(budgetAccountValuesAtPostingDate));
        }
        public async Task ApplyCalculationAsync_WhenCalled_ReturnsSamePostingLineWhereBudgetAccountIsEqualToCalculatedBudgetAccount()
        {
            IPostingLine sut = CreateSut();

            IBudgetAccount calculatedBudgetAccount = _fixture.BuildBudgetAccountMock().Object;
            IPostingLine   result = await sut.ApplyCalculationAsync(calculatedBudgetAccount);

            Assert.That(result.BudgetAccount, Is.EqualTo(calculatedBudgetAccount));
        }
Example #7
0
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereAccountValuesAtPostingDateWasGiven_ReturnsSamePostingLineWhereAccountValuesAtPostingDateNotEqualToNull()
        {
            ICreditInfoValues accountValuesAtPostingDate = _fixture.BuildCreditInfoValuesMock().Object;
            IPostingLine      sut = CreateSut(accountValuesAtPostingDate: accountValuesAtPostingDate);

            IPostingLine result = await sut.ApplyCalculationAsync(_fixture.BuildAccountMock().Object);

            Assert.That(result.AccountValuesAtPostingDate, Is.Not.Null);
        }
Example #8
0
        public async Task ApplyCalculationAsync_WhenCalled_ReturnsSamePostingLineWhereAccountingIsEqualToCalculatedAccounting()
        {
            IPostingLine sut = CreateSut();

            IAccounting  calculatedAccounting = _fixture.BuildAccountingMock().Object;
            IPostingLine result = await sut.ApplyCalculationAsync(calculatedAccounting);

            Assert.That(result.Accounting, Is.EqualTo(calculatedAccounting));
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasNotGivenAndCalculatedBudgetAccountDoesNotHaveBudgetInfoForPostingDate_ReturnsSamePostingLineWhereBudgetOnBudgetAccountValuesAtPostingDateEqualToZero()
        {
            IPostingLine sut = CreateSut();

            IBudgetInfoCollection budgetInfoCollection    = _fixture.BuildBudgetInfoCollectionMock(hasBudgetInfoForFind: false).Object;
            IBudgetAccount        calculatedBudgetAccount = _fixture.BuildBudgetAccountMock(budgetInfoCollection: budgetInfoCollection).Object;
            IPostingLine          result = await sut.ApplyCalculationAsync(calculatedBudgetAccount);

            Assert.That(result.BudgetAccountValuesAtPostingDate.Budget, Is.EqualTo(0M));
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasGiven_AssertBudgetInfoCollectionWasNotCalledOnCalculatedBudgetAccount()
        {
            IBudgetInfoValues budgetAccountValuesAtPostingDate = _fixture.BuildBudgetInfoMock().Object;
            IPostingLine      sut = CreateSut(budgetAccountValuesAtPostingDate: budgetAccountValuesAtPostingDate);

            Mock <IBudgetAccount> calculatedBudgetAccountMock = _fixture.BuildBudgetAccountMock();
            await sut.ApplyCalculationAsync(calculatedBudgetAccountMock.Object);

            calculatedBudgetAccountMock.Verify(m => m.BudgetInfoCollection, Times.Never);
        }
Example #11
0
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereAccountValuesAtPostingDateWasGiven_AssertPostingLineCollectionWasNotCalledOnCalculatedAccount()
        {
            ICreditInfoValues accountValuesAtPostingDate = _fixture.BuildCreditInfoValuesMock().Object;
            IPostingLine      sut = CreateSut(accountValuesAtPostingDate: accountValuesAtPostingDate);

            Mock <IAccount> calculatedAccountMock = _fixture.BuildAccountMock();
            await sut.ApplyCalculationAsync(calculatedAccountMock.Object);

            calculatedAccountMock.Verify(m => m.PostingLineCollection, Times.Never);
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasNotGiven_AssertFindWasCalledOnBudgetInfoCollectionFromCalculatedBudgetAccount()
        {
            DateTime     postingDate = DateTime.Today.AddDays(_random.Next(-120, 120));
            IPostingLine sut         = CreateSut(postingDate);

            Mock <IBudgetInfoCollection> budgetInfoCollectionMock = _fixture.BuildBudgetInfoCollectionMock();
            IBudgetAccount calculatedBudgetAccount = _fixture.BuildBudgetAccountMock(budgetInfoCollection: budgetInfoCollectionMock.Object).Object;
            await sut.ApplyCalculationAsync(calculatedBudgetAccount);

            budgetInfoCollectionMock.Verify(m => m.Find(It.Is <DateTime>(value => value == postingDate)), Times.Once);
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasNotGiven_ReturnsSamePostingLineWherePostedOnBudgetAccountValuesAtPostingDateEqualToCalculatedPostingValueFromPostingLineCollection()
        {
            IPostingLine sut = CreateSut();

            decimal calculatedPostingValue = _fixture.Create <decimal>();
            IPostingLineCollection postingLineCollection   = _fixture.BuildPostingLineCollectionMock(calculatedPostingValue: calculatedPostingValue, isEmpty: true).Object;
            IBudgetAccount         calculatedBudgetAccount = _fixture.BuildBudgetAccountMock(postingLineCollection: postingLineCollection).Object;
            IPostingLine           result = await sut.ApplyCalculationAsync(calculatedBudgetAccount);

            Assert.That(result.BudgetAccountValuesAtPostingDate.Posted, Is.EqualTo(calculatedPostingValue));
        }
Example #14
0
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereAccountValuesAtPostingDateWasNotGivenAndCalculatedAccountHasCreditInfoForPostingDate_ReturnsSamePostingLineWhereCreditOnAccountValuesAtPostingDateEqualToCreditFromCreditInfoForPostingDate()
        {
            IPostingLine sut = CreateSut();

            ICreditInfo           creditInfo           = _fixture.BuildCreditInfoMock().Object;
            ICreditInfoCollection creditInfoCollection = _fixture.BuildCreditInfoCollectionMock(creditInfoForFind: creditInfo).Object;
            IAccount     calculatedAccount             = _fixture.BuildAccountMock(creditInfoCollection: creditInfoCollection).Object;
            IPostingLine result = await sut.ApplyCalculationAsync(calculatedAccount);

            Assert.That(result.AccountValuesAtPostingDate.Credit, Is.EqualTo(creditInfo.Credit));
        }
        public async Task ApplyCalculationAsync_WhenCalledOnPostingLineWhereBudgetAccountValuesAtPostingDateWasNotGiven_AssertCalculatePostingValueWasCalledOnPostingLineCollectionFromCalculatedBudgetAccount()
        {
            DateTime     postingDate = DateTime.Today.AddDays(_random.Next(-120, 120));
            int          sortOrder   = _fixture.Create <int>();
            IPostingLine sut         = CreateSut(postingDate, sortOrder);

            Mock <IPostingLineCollection> postingLineCollectionMock = _fixture.BuildPostingLineCollectionMock();
            IBudgetAccount calculatedBudgetAccount = _fixture.BuildBudgetAccountMock(postingLineCollection: postingLineCollectionMock.Object).Object;
            await sut.ApplyCalculationAsync(calculatedBudgetAccount);

            postingLineCollectionMock.Verify(m => m.CalculatePostingValue(
                                                 It.Is <DateTime>(value => value == new DateTime(postingDate.Year, postingDate.Month, 1)),
                                                 It.Is <DateTime>(value => value == postingDate),
                                                 It.Is <int?>(value => value == sortOrder)),
                                             Times.Once);
        }
        public void ApplyCalculationAsync_WhenCalculatedBudgetAccountIsNull_ThrowsArgumentNullException()
        {
            IPostingLine sut = CreateSut();

            ArgumentNullException result = Assert.ThrowsAsync <ArgumentNullException>(async() => await sut.ApplyCalculationAsync((IBudgetAccount)null));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ParamName, Is.EqualTo("calculatedBudgetAccount"));
            // ReSharper restore PossibleNullReferenceException
        }