public static SalesOrderItemBuilder WithDefaults(this SalesOrderItemBuilder @this) { var faker = @this.Session.Faker(); var invoiceItemTypes = @this.Session.Extent <InvoiceItemType>().ToList(); var otherInvoiceItemTypes = invoiceItemTypes.Except( invoiceItemTypes.Where(v => v.UniqueId.Equals(InvoiceItemTypes.ProductItemId) || v.UniqueId.Equals(InvoiceItemTypes.PartItemId)).ToList()) .ToList(); var unifiedGoodExtent = @this.Session.Extent <UnifiedGood>(); unifiedGoodExtent.Filter.AddEquals(M.UnifiedGood.InventoryItemKind.RoleType, new InventoryItemKinds(@this.Session).Serialised); var serializedProduct = unifiedGoodExtent.First(); @this.WithDescription(faker.Lorem.Sentences(2)); @this.WithComment(faker.Lorem.Sentence()); @this.WithInternalComment(faker.Lorem.Sentence()); @this.WithInvoiceItemType(faker.Random.ListItem(otherInvoiceItemTypes)); @this.WithProduct(serializedProduct); @this.WithSerialisedItem(serializedProduct.SerialisedItems.First); @this.WithNextSerialisedItemAvailability(faker.Random.ListItem(@this.Session.Extent <SerialisedItemAvailability>())); @this.WithQuantityOrdered(1); @this.WithAssignedUnitPrice(faker.Random.UInt()); return(@this); }
public static SalesOrderItemBuilder WithNonSerialisedProductItemDefaults(this SalesOrderItemBuilder @this) { var faker = @this.Session.Faker(); var invoiceItemType = @this.Session.Extent <InvoiceItemType>().FirstOrDefault(v => v.UniqueId.Equals(InvoiceItemTypes.ProductItemId)); var unifiedGoodExtent = @this.Session.Extent <UnifiedGood>(); unifiedGoodExtent.Filter.AddEquals(M.UnifiedGood.InventoryItemKind.RoleType, new InventoryItemKinds(@this.Session).NonSerialised); var nonSerializedProduct = unifiedGoodExtent.First(); @this.WithDescription(faker.Lorem.Sentences(2)); @this.WithComment(faker.Lorem.Sentence()); @this.WithInternalComment(faker.Lorem.Sentence()); @this.WithInvoiceItemType(invoiceItemType); @this.WithProduct(nonSerializedProduct); @this.WithQuantityOrdered(1); @this.WithAssignedUnitPrice(faker.Random.UInt()); return(@this); }