public void GivenPurchaseShipment_WhenDeriving_ThenRequiredRelationsMustExist() { var supplier = new OrganisationBuilder(this.Session).WithName("supplier").Build(); this.Session.Commit(); var builder = new PurchaseShipmentBuilder(this.Session); builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithShipmentMethod(new ShipmentMethods(this.Session).Ground); builder.Build(); Assert.True(this.Session.Derive(false).HasErrors); this.Session.Rollback(); builder.WithShipFromParty(supplier); builder.Build(); Assert.False(this.Session.Derive(false).HasErrors); }
public static PurchaseShipmentBuilder WithDefaults(this PurchaseShipmentBuilder @this, Organisation internalOrganisation) { var faker = @this.Session.Faker(); var supplier = faker.Random.ListItem(internalOrganisation.ActiveSuppliers); @this.WithShipFromParty(supplier); @this.WithShipFromContactPerson(supplier.CurrentContacts.FirstOrDefault()); @this.WithShipToParty(internalOrganisation); @this.WithShipToContactPerson(internalOrganisation.CurrentContacts.FirstOrDefault()); @this.WithShipmentMethod(faker.Random.ListItem(@this.Session.Extent <ShipmentMethod>())); @this.WithCarrier(faker.Random.ListItem(@this.Session.Extent <Carrier>())); @this.WithEstimatedShipDate(faker.Date.Between(start: @this.Session.Now(), end: @this.Session.Now().AddDays(5))); @this.WithEstimatedArrivalDate(faker.Date.Between(start: @this.Session.Now().AddDays(6), end: @this.Session.Now().AddDays(10))); @this.WithElectronicDocument(new MediaBuilder(@this.Session).WithInFileName("doc1.en.pdf").WithInData(faker.Random.Bytes(1000)).Build()); @this.WithEstimatedShipCost(faker.Finance.Amount(100, 1000, 2)); @this.WithComment(faker.Lorem.Sentence()); foreach (Locale additionalLocale in @this.Session.GetSingleton().AdditionalLocales) { @this.WithLocalisedComment(new LocalisedTextBuilder(@this.Session).WithText(faker.Lorem.Sentence()).WithLocale(additionalLocale).Build()); } return(@this); }
public void GivenPurchaseShipment_WhenDeriving_ThenRequiredRelationsMustExist() { var supplier = new OrganisationBuilder(this.DatabaseSession).WithName("supplier").Build(); this.DatabaseSession.Commit(); var builder = new PurchaseShipmentBuilder(this.DatabaseSession); builder.Build(); Assert.IsTrue(this.DatabaseSession.Derive().HasErrors); this.DatabaseSession.Rollback(); builder.WithShipFromParty(supplier); builder.Build(); Assert.IsFalse(this.DatabaseSession.Derive().HasErrors); }