/// <summary> /// Initializes a new instance of the <see cref="AggregatedItemServices"/> class. /// </summary> /// <param name="itemMergeStrategyHandler">An non null-implementation of <see cref="IItemMergeStrategyHandler"/>.</param> /// <param name="itemSplitStrategyHandler">An non null-implementation of <see cref="IItemSplitStrategyHandler"/>.</param> /// <param name="itemFactory">An non null-implementation of <see cref="IItemFactory"/>.</param> public AggregatedItemServices( IItemMergeStrategyHandler itemMergeStrategyHandler, IItemSplitStrategyHandler itemSplitStrategyHandler, IItemFactory itemFactory) { this.ItemMergeStrategyHandler = itemMergeStrategyHandler; this.ItemSplitStrategyHandler = itemSplitStrategyHandler; this.ItemFactory = itemFactory; }
public static AggregatedItemServices CreateItemServices( IItemMergeStrategyHandler mergeStrategyHandler = null, IItemSplitStrategyHandler splitStrategyHandler = null, IItemFactory itemFactory = null ) { if (mergeStrategyHandler == null) { mergeStrategyHandler = new ItemMergeStrategyHandler(); } if (splitStrategyHandler == null) { splitStrategyHandler = new ItemSplitStrategyHandler(); } if (itemFactory == null) { itemFactory = new Mock <IItemFactory>().Object; } return(new AggregatedItemServices(mergeStrategyHandler, splitStrategyHandler, itemFactory)); }
protected void SetupServiceProvider(params ItemMeta[] itemMetas) { this.SetupDependencies(); foreach (var itemMeta in itemMetas) { this.ItemRegistry.AddItemMeta(itemMeta); } this.ServiceCollection.AddItemTypes(this.ItemRegistry); this.ServiceProvider = this.ServiceCollection.BuildServiceProvider(); this.ItemFactory = this.ServiceProvider.GetRequiredService <IItemFactory>(); this.ItemServices = this.ServiceProvider.GetRequiredService <AggregatedItemServices>(); this.InventoryFactory = this.ServiceProvider.GetRequiredService <IInventoryFactory>(); this.InventoryServices = this.ServiceProvider.GetRequiredService <AggregatedInventoryServices>(); this.ItemSplitStrategyHandler = this.ServiceProvider.GetRequiredService <IItemSplitStrategyHandler>(); this.ItemMergeStrategyHandler = this.ServiceProvider.GetRequiredService <IItemMergeStrategyHandler>(); this.Item = (Item)this.ItemFactory.CreateItem(itemMetas.First(), 1); this.Inventory = this.InventoryFactory.CreateInventory(100); }