Exemplo n.º 1
0
 private static Sut CreateTransactionEntry(Peent.Domain.Entities.TransactionAggregate.Transaction transaction)
 {
     return(new Sut(
                transaction,
                F.Create <Peent.Domain.Entities.Account>(),
                F.Create <Money>()));
 }
Exemplo n.º 2
0
        public void when_transaction_is_null__throws_argument_exception()
        {
            Peent.Domain.Entities.TransactionAggregate.Transaction transaction = null;

            Action act = () => CreateTransactionEntry(transaction);

            act.Should().Throw <ArgumentException>()
            .WithMessage($"*{nameof(Sut.Transaction).FirstDown()}*");
        }
Exemplo n.º 3
0
        public void when_tags_are_null__does_not_throw()
        {
            var transaction = new Sut(
                _fixture.Create <string>(),
                _fixture.Create <DateTime>(),
                _fixture.Create <CategoryEntity>(),
                _fixture.Create <decimal>(),
                _fixture.Create <AccountEntity>(),
                _fixture.Create <AccountEntity>(),
                tags: null);

            transaction.TransactionTags.Should().BeEmpty();
        }
Exemplo n.º 4
0
        public void when_all_parameters_are_valid__correctly_set_properties()
        {
            var title       = _fixture.Create <string>();
            var date        = _fixture.Create <DateTime>();
            var description = _fixture.Create <string>();
            var category    = _fixture.Create <CategoryEntity>();
            var tags        = _fixture.Create <List <TagEntity> >();
            var amount      = _fixture.Create <decimal>();
            var fromAccount = _fixture.Create <AccountEntity>();
            var toAccount   = _fixture.Create <AccountEntity>();

            var transaction = new Sut(title, date, description, category, amount, fromAccount, toAccount, tags);

            transaction.Title.Should().Be(title);
            transaction.Date.Should().Be(date);
            transaction.Description.Should().Be(description);
            transaction.Category.Should().Be(category);
            transaction.TransactionTags.Select(x => x.Tag).Should().BeEquivalentTo(tags);
            transaction.Entries.Should().HaveCount(2);
            transaction.Entries.First().Account.Should().Be(fromAccount);
            transaction.Entries.First().Money.Should().Be(new Money(amount, fromAccount.Currency));
            transaction.Entries.Last().Account.Should().Be(toAccount);
            transaction.Entries.Last().Money.Should().Be(new Money(-amount, toAccount.Currency));
        }