Ejemplo n.º 1
0
        public void Add_WhenPostingLineCollectionIsNotNullAndOnePostingLineDoesExistWithinCollection_ThrowsIntranetSystemException()
        {
            IPostingLineCollection sut = CreateSut();

            IList <IPostingLine> postingLineCollection = new List <IPostingLine>
            {
                _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object,
                                 _fixture.BuildPostingLineMock().Object
            };

            IPostingLine existingPostingLine = postingLineCollection[_random.Next(0, postingLineCollection.Count - 1)];

            sut.Add(existingPostingLine);

            IntranetSystemException result = Assert.Throws <IntranetSystemException>(() => sut.Add(postingLineCollection));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.Message.Contains(existingPostingLine.GetType().Name), Is.True);
            // ReSharper restore PossibleNullReferenceException
            Assert.That(result.ErrorCode, Is.EqualTo(ErrorCode.ObjectAlreadyExists));
            Assert.That(result.InnerException, Is.Null);
        }
        public async Task GetPostingLinesAsync_WhenCalledOnAccountWithNonEmptyAccountCollection_ReturnsPostingLineCollectionWithPostingLinesUpToStatusDate()
        {
            DateTime     statusDate = DateTime.Today.AddDays(_random.Next(1, 7) * -1);
            IPostingLine postingLine1BeforeStatusDate = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7) * -1)).Object;
            IPostingLine postingLine2BeforeStatusDate = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7) * -1)).Object;
            IPostingLine postingLine3BeforeStatusDate = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7) * -1)).Object;
            IPostingLine postingLine1OnStatusDate     = _fixture.BuildPostingLineMock(postingDate: statusDate).Object;
            IPostingLine postingLine2OnStatusDate     = _fixture.BuildPostingLineMock(postingDate: statusDate).Object;
            IPostingLine postingLine3OnStatusDate     = _fixture.BuildPostingLineMock(postingDate: statusDate).Object;
            IPostingLine postingLine1AfterStatusDate  = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7))).Object;
            IPostingLine postingLine2AfterStatusDate  = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7))).Object;
            IPostingLine postingLine3AfterStatusDate  = _fixture.BuildPostingLineMock(postingDate: statusDate.AddDays(_random.Next(1, 7))).Object;

            IAccount[] accountCollection =
            {
                _fixture.BuildAccountMock(postingLineCollection: _fixture.BuildPostingLineCollectionMock(postingLineCollection: new[] { postingLine1BeforeStatusDate, postingLine1OnStatusDate, postingLine1AfterStatusDate }).Object).Object,
                _fixture.BuildAccountMock(postingLineCollection: _fixture.BuildPostingLineCollectionMock(postingLineCollection: new[] { postingLine2BeforeStatusDate, postingLine2OnStatusDate, postingLine2AfterStatusDate }).Object).Object,
                _fixture.BuildAccountMock(postingLineCollection: _fixture.BuildPostingLineCollectionMock(postingLineCollection: new[] { postingLine3BeforeStatusDate, postingLine3OnStatusDate, postingLine3AfterStatusDate }).Object).Object
            };
            IAccounting sut = CreateSut(accountCollection);

            IPostingLineCollection result = await sut.GetPostingLinesAsync(statusDate);

            Assert.That(result.Contains(postingLine1BeforeStatusDate), Is.True);
            Assert.That(result.Contains(postingLine2BeforeStatusDate), Is.True);
            Assert.That(result.Contains(postingLine3BeforeStatusDate), Is.True);
            Assert.That(result.Contains(postingLine1OnStatusDate), Is.True);
            Assert.That(result.Contains(postingLine2OnStatusDate), Is.True);
            Assert.That(result.Contains(postingLine3OnStatusDate), Is.True);
            Assert.That(result.Contains(postingLine1AfterStatusDate), Is.False);
            Assert.That(result.Contains(postingLine2AfterStatusDate), Is.False);
            Assert.That(result.Contains(postingLine3AfterStatusDate), Is.False);
        }
Ejemplo n.º 3
0
        public void ToDomain_WhenCalledApplyPostingLineCommandHasContactAccountNumber_ReturnsPostingLineWhereContactAccountNotEqualToNull()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.ContactAccount, Is.Not.Null);
        }
Ejemplo n.º 4
0
        public void ToDomain_WhenCalledApplyPostingLineCommandHasNoCredit_ReturnsPostingLineWhereCreditEqualToZero()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, hasCredit: false);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.Credit, Is.EqualTo(0M));
        }
Ejemplo n.º 5
0
        public void ToDomain_WhenCalledApplyPostingLineCommandHasNoBudgetAccountNumber_ReturnsPostingLineWhereBudgetAccountEqualToNull()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, hasBudgetAccountNumber: false);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.BudgetAccount, Is.Null);
        }
Ejemplo n.º 6
0
        public void ToDomain_WhenCalled_ReturnsPostingLineWhereDetailsNotEqualToNull()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.Details, Is.Not.Null);
        }
Ejemplo n.º 7
0
        public void ToDomain_WhenApplyPostingLineCommandHasReference_ReturnsPostingLineWhereReferenceNotEqualToNull()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.Reference, Is.Not.Null);
        }
Ejemplo n.º 8
0
        public void ToDomain_WhenApplyPostingLineCommandHasNoIdentifier_ReturnsPostingLineWhereIdentifierNotEqualToGuidEmpty()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.Identifier, Is.Not.EqualTo(Guid.Empty));
        }
        public void Equals_WhenObjectIsPostingLineWhereIdentifierDoesNotMatch_ReturnsFalse()
        {
            IPostingLine sut = CreateSut();

            bool result = sut.Equals(CreateSut());

            Assert.That(result, Is.False);
        }
        public void Equals_WhenObjectIsNonPostingLine_ReturnsFalse()
        {
            IPostingLine sut = CreateSut();

            bool result = sut.Equals(_fixture.Create <object>());

            Assert.That(result, Is.False);
        }
        public void Equals_WhenObjectIsNull_ReturnsFalse()
        {
            IPostingLine sut = CreateSut();

            bool result = sut.Equals(null);

            Assert.That(result, Is.False);
        }
        public void BudgetAccountValuesAtPostingDate_WhenCalculateAsyncHasNotBeenCalledOnPostingLineWithBudgetAccount_ReturnsCreditInfoValuesWherePostedIsEqualToZero()
        {
            IPostingLine sut = CreateSut();

            IBudgetInfoValues result = sut.BudgetAccountValuesAtPostingDate;

            Assert.That(result.Posted, Is.EqualTo(0M));
        }
Ejemplo n.º 13
0
        public void ToDomain_WhenCalled_ReturnsPostingLine()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result, Is.TypeOf <PostingLine>());
        }
        public async Task CalculateAsync_WhenCalled_ReturnsSamePostingLine()
        {
            IPostingLine sut = CreateSut();

            IPostingLine result = await sut.CalculateAsync(DateTime.Now.AddDays(_random.Next(1, 365) * -1));

            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);
        }
Ejemplo n.º 17
0
        public async Task ApplyCalculationAsync_WhenCalled_ReturnsSamePostingLine()
        {
            IPostingLine sut = CreateSut();

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

            Assert.That(result, Is.SameAs(sut));
        }
Ejemplo n.º 18
0
        public void AccountValuesAtPostingDate_WhenCalculateAsyncHasNotBeenCalled_ReturnsCreditInfoValuesWhereBalanceIsEqualToZero()
        {
            IPostingLine sut = CreateSut();

            ICreditInfoValues result = sut.AccountValuesAtPostingDate;

            Assert.That(result.Balance, Is.EqualTo(0M));
        }
Ejemplo n.º 19
0
        private Mock <IApplyPostingLineCommand> CreateApplyPostingLineCommandMock(IPostingLine postingLine = null)
        {
            Mock <IApplyPostingLineCommand> applyPostingLineCommandMock = new Mock <IApplyPostingLineCommand>();

            applyPostingLineCommandMock.Setup(m => m.ToDomain(It.IsAny <IAccounting>()))
            .Returns(postingLine ?? _fixture.BuildPostingLineMock().Object);
            return(applyPostingLineCommandMock);
        }
Ejemplo n.º 20
0
        public void ContactAccountValuesAtPostingDate_WhenCalculateAsyncHasNotBeenCalledOnPostingLineWithContactAccount_ReturnsNotNull()
        {
            IPostingLine sut = CreateSut();

            IContactInfoValues result = sut.ContactAccountValuesAtPostingDate;

            Assert.That(result, Is.Not.Null);
        }
Ejemplo n.º 21
0
        public void AccountValuesAtPostingDate_WhenCalculateAsyncHasNotBeenCalled_ReturnsNotNull()
        {
            IPostingLine sut = CreateSut();

            ICreditInfoValues result = sut.AccountValuesAtPostingDate;

            Assert.That(result, Is.Not.Null);
        }
        public void BudgetAccountValuesAtPostingDate_WhenCalculateAsyncHasNotBeenCalledOnPostingLineWithoutBudgetAccount_ReturnsNull()
        {
            IPostingLine sut = CreateSut(false);

            IBudgetInfoValues result = sut.BudgetAccountValuesAtPostingDate;

            Assert.That(result, Is.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));
        }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
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));
        }
Ejemplo n.º 28
0
        public void ToDomain_WhenCalledApplyPostingLineCommandHasCredit_ReturnsPostingLineWhereCreditEqualToCreditFromApplyPostingLineCommand()
        {
            decimal credit = _fixture.Create <decimal>();
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, credit: credit);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.Credit, Is.EqualTo(credit));
        }
Ejemplo n.º 29
0
        public void ToDomain_WhenCalledApplyPostingLineCommandHasContactAccountNumber_ReturnsPostingLineWhereContactAccountMatchesContactAccountNumberFromApplyPostingLineCommand()
        {
            string contactAccountNumber  = _fixture.Create <string>();
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, contactAccountNumber: contactAccountNumber);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.ContactAccount.AccountNumber, Is.EqualTo(contactAccountNumber.ToUpper()));
        }
Ejemplo n.º 30
0
        public void ToDomain_WhenCalled_ReturnsPostingLineWhereSortOrderEqualToSortOrderFromApplyPostingLineCommand()
        {
            int sortOrder = _fixture.Create <int>();
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, sortOrder: sortOrder);

            IPostingLine result = sut.ToDomain(accountingMock.Object);

            Assert.That(result.SortOrder, Is.EqualTo(sortOrder));
        }