public void Setup() { this.itemRegistry = new Mock <IItemRegistry>(); this.inventoryServices = new AggregatedInventoryServices(this.itemRegistry.Object); this.inventoryFactory = new InventoryFactory(this.inventoryServices); }
public void CreatingAggregatedInventoryServiceSetsRightValues() { var itemRegistry = new Mock <IItemRegistry>(); var service = new AggregatedInventoryServices(itemRegistry.Object); service.ItemRegistry.Should().Be(itemRegistry.Object); }
/// <summary> /// Initializes a new instance of the <see cref="Inventory"/> class. /// </summary> /// <param name="capacity">Capacity of this inventory.</param> /// <param name="inventoryServices">Needed services of this inventory.</param> /// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is too low.</exception> public Inventory(int capacity, AggregatedInventoryServices inventoryServices) { if (capacity < MinimalInventoryCapacity) { throw new ArgumentOutOfRangeException(nameof(capacity), $"The capacity has to be {MinimalInventoryCapacity} or higher"); } this.itemRegistry = inventoryServices.ItemRegistry; this.items = new ConcurrentDictionary <Guid, IItem>(); this.RuntimeId = Guid.NewGuid(); this.UsedCapacity = 0; this.Capacity = capacity; }
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); }
/// <summary> /// Initializes a new instance of the <see cref="InventoryFactory"/> class. /// </summary> /// <param name="inventoryServices">Services which are required to run a default <see cref="Inventory"/> instance.</param> public InventoryFactory(AggregatedInventoryServices inventoryServices) { this.inventoryServices = inventoryServices; }
public void CreatingAggregatedInventoryServiceSetsRightNullValues() { var service = new AggregatedInventoryServices(null); service.ItemRegistry.Should().BeNull(); }