Example #1
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));
        }
Example #2
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));
        }
Example #3
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>());
        }
Example #4
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);
        }
Example #5
0
        public void ToDomain_WhenCalled_AssertContactAccountCollectionWasCalledOnAccounting()
        {
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock);

            sut.ToDomain(accountingMock.Object);

            accountingMock.Verify(m => m.ContactAccountCollection, Times.Once);
        }
Example #6
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);
        }
Example #7
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);
        }
Example #8
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);
        }
Example #9
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));
        }
Example #10
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()));
        }
Example #11
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));
        }
Example #12
0
        public void ToDomain_WhenApplyPostingLineCommandHasIdentifier_ReturnsPostingLineWhereIdentifierEqualToIdentifierFromApplyPostingLineCommand()
        {
            Guid identifier = Guid.NewGuid();
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, true, identifier);

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

            Assert.That(result.Identifier, Is.EqualTo(identifier));
        }
Example #13
0
        public void ToDomain_WhenCalled_ReturnsPostingLineWhereDetailsEqualToDetailsFromApplyPostingLineCommand()
        {
            string details = _fixture.Create <string>();
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, details: details);

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

            Assert.That(result.Details, Is.EqualTo(details));
        }
Example #14
0
        public void ToDomain_WhenApplyPostingLineCommandHasReference_ReturnsPostingLineWhereReferenceEqualToReferenceFromApplyPostingLineCommand()
        {
            string reference             = _fixture.Create <string>();
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, reference: reference);

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

            Assert.That(result.Reference, Is.EqualTo(reference));
        }
Example #15
0
        public void ToDomain_WhenCalled_ReturnsPostingLineWherePostingDateEqualToPostingDateFromApplyPostingLineCommand()
        {
            DateTime postingDate         = DateTime.Today.AddDays(_random.Next(0, 30) * -1).AddMinutes(_random.Next(8 * 60, 16 * 60));
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock, postingDate: postingDate);

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

            Assert.That(result.PostingDate, Is.EqualTo(postingDate.Date));
        }
Example #16
0
        public void ToDomain_WhenAccountingIsNull_ThrowsArgumentNullException()
        {
            // ReSharper disable UnusedVariable
            IApplyPostingLineCommand sut = CreateSut(out Mock <IAccounting> accountingMock);
            // ReSharper restore UnusedVariable

            ArgumentNullException result = Assert.Throws <ArgumentNullException>(() => sut.ToDomain(null));

            // ReSharper disable PossibleNullReferenceException
            Assert.That(result.ParamName, Is.EqualTo("accounting"));
            // ReSharper restore PossibleNullReferenceException
        }
Example #17
0
        protected static bool IsMatch(IApplyPostingLineCommand applyPostingLineCommand, ApplyPostingLineModel applyPostingLineModel)
        {
            NullGuard.NotNull(applyPostingLineCommand, nameof(applyPostingLineCommand))
            .NotNull(applyPostingLineModel, nameof(applyPostingLineModel));

            return(applyPostingLineCommand.Identifier == applyPostingLineModel.Identifier &&
                   applyPostingLineCommand.PostingDate == applyPostingLineModel.PostingDate.Date &&
                   applyPostingLineCommand.Reference == (string.IsNullOrWhiteSpace(applyPostingLineModel.Reference) ? null : applyPostingLineModel.Reference) &&
                   applyPostingLineCommand.AccountNumber == applyPostingLineModel.AccountNumber.ToUpper() &&
                   applyPostingLineCommand.Details == applyPostingLineModel.Details &&
                   applyPostingLineCommand.BudgetAccountNumber == (string.IsNullOrWhiteSpace(applyPostingLineModel.BudgetAccountNumber) ? null : applyPostingLineModel.BudgetAccountNumber.ToUpper()) &&
                   applyPostingLineCommand.Debit == applyPostingLineModel.Debit &&
                   applyPostingLineCommand.Credit == applyPostingLineModel.Credit &&
                   applyPostingLineCommand.ContactAccountNumber == (string.IsNullOrWhiteSpace(applyPostingLineModel.ContactAccountNumber) ? null : applyPostingLineModel.ContactAccountNumber.ToUpper()) &&
                   applyPostingLineCommand.SortOrder == (applyPostingLineModel.SortOrder ?? 0));
        }