public void GivenTaxDue_WhenDeriving_ThenRequiredRelationsMustExist() { var partyFrom = new OrganisationBuilder(this.DatabaseSession).WithName("party from").Build(); var partyTo = new OrganisationBuilder(this.DatabaseSession).WithName("party to").Build(); this.DatabaseSession.Derive(true); this.DatabaseSession.Commit(); var builder = new TaxDueBuilder(this.DatabaseSession); var taxDue = builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithDescription("taxdue"); taxDue = builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithEntryDate(DateTime.UtcNow); taxDue = builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithTransactionDate(DateTime.UtcNow.AddYears(1)); taxDue = builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithFromParty(partyFrom); taxDue = builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithToParty(partyTo); taxDue = builder.Build(); Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); }
public void GivenTaxDue_WhenDeriving_ThenRequiredRelationsMustExist() { var partyFrom = new OrganisationBuilder(this.Session).WithName("party from").Build(); var partyTo = new OrganisationBuilder(this.Session).WithName("party to").Build(); this.Session.Derive(); this.Session.Commit(); var builder = new TaxDueBuilder(this.Session); var taxDue = builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithDescription("taxdue"); taxDue = builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithEntryDate(DateTime.UtcNow); taxDue = builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithTransactionDate(DateTime.UtcNow.AddYears(1)); taxDue = builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithFromParty(partyFrom); taxDue = builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithToParty(partyTo); taxDue = builder.Build(); Assert.False(this.Session.Derive(false).HasErrors); }