public void TransferProp_Equipment() { // ARRANGE var equipmentScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; // Инвентарь var inventory = new InventoryModule(); // контейнер var containerProps = new IProp[] { new Equipment(equipmentScheme, System.Array.Empty <ITacticalActScheme>()) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT var transferResource = containerProps.First(); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT transferMachine.Inventory.PropAdded[0].Should().BeOfType <Equipment>(); transferMachine.Container.PropRemoved[0].Should().BeOfType <Equipment>(); }
public void TransferProp_Resources() { // ARRANGE var resourceScheme = new TestPropScheme(); // Инвентарь var inventory = new InventoryModule(); // контейнер var containerProps = new IProp[] { new Resource(resourceScheme, 1) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT var transferResource = new Resource(resourceScheme, 1); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT transferMachine.Inventory.PropAdded[0].Should().BeOfType <Resource>(); var invResource = (Resource)transferMachine.Inventory.PropAdded[0]; invResource.Count.Should().Be(1); }
public void TransferProp_Equipment_StoreEventsRaised() { // ARRANGE var equipmentScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; // Инвентарь var inventory = new InventoryModule(); // контейнер var containerProps = new IProp[] { new Equipment(equipmentScheme, System.Array.Empty <ITacticalActScheme>()) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT using var monitorInventory = transferMachine.Inventory.Monitor(); using var monitorContainer = transferMachine.Container.Monitor(); var transferResource = containerProps.First(); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT monitorInventory.Should().Raise(nameof(PropTransferStore.Added)); monitorContainer.Should().Raise(nameof(PropTransferStore.Removed)); }
public void TransferProp_ChangesResources_StoreEventsRaised() { // ARRANGE var resourceScheme = new TestPropScheme(); // Инвентарь var inventory = new InventoryModule(); inventory.Add(new Resource(resourceScheme, 1)); // контейнер var containerProps = new IProp[] { new Resource(resourceScheme, 2) }; var container = new FixedPropChest(containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT using var monitorInventory = transferMachine.Inventory.Monitor(); using var monitorContainer = transferMachine.Container.Monitor(); var transferResource = new Resource(resourceScheme, 1); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT monitorInventory.Should().Raise(nameof(PropTransferStore.Changed)); monitorContainer.Should().Raise(nameof(PropTransferStore.Changed)); }
public IPropContainer AddChest(int id, OffsetCoords nodeCoords) { var containerManager = Container.GetInstance <IPropContainerManager>(); var sector = Container.GetInstance <ISector>(); var node = sector.Map.Nodes.Cast <HexNode>().SelectBy(nodeCoords.X, nodeCoords.Y); var chest = new FixedPropChest(node, new IProp[0], id); containerManager.Add(chest); return(chest); }
public IPropContainer AddChest(int id, OffsetCoords nodeCoords) { var sector = GetCurrentGlobeFirstSector(); var node = sector.Map.Nodes.SelectByHexCoords(nodeCoords.X, nodeCoords.Y); var chest = new FixedPropChest(Array.Empty <IProp>()); var staticObject = new StaticObject(node, chest.Purpose, id); staticObject.AddModule <IPropContainer>(chest); sector.StaticObjectManager.Add(staticObject); return(chest); }
public void TransferProp_InventoryHasEquipment_StoreEventsRaised() { // ARRANGE var equipmentScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; // Инвентарь var inventory = new Inventory(); inventory.Add(new Equipment(equipmentScheme, new ITacticalActScheme[0])); // контейнер var containerProps = new IProp[] { new Equipment(equipmentScheme, new ITacticalActScheme[0]) }; var nodeMock = new Mock <IMapNode>(); var node = nodeMock.Object; var container = new FixedPropChest(node, containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT using (var monitorInventory = transferMachine.Inventory.Monitor()) using (var monitorContainer = transferMachine.Container.Monitor()) { var transferResource = containerProps.First(); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT monitorInventory.Should().Raise(nameof(PropTransferStore.Added)); monitorContainer.Should().Raise(nameof(PropTransferStore.Removed)); } }
public void TransferProp_Resources_StoreEventsRaised() { // ARRANGE var resourceScheme = new TestPropScheme(); var resource = new Resource(resourceScheme, 1); // Инвентарь var inventory = new Inventory(); // контейнер var containerProps = new IProp[] { resource }; var nodeMock = new Mock <IMapNode>(); var node = nodeMock.Object; var container = new FixedPropChest(node, containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT using (var monitorInventory = transferMachine.Inventory.Monitor()) using (var monitorContainer = transferMachine.Container.Monitor()) { var transferResource = new Resource(resourceScheme, 1); transferMachine.TransferProp(transferResource, PropTransferMachineStores.Container, PropTransferMachineStores.Inventory); // ASSERT monitorInventory.Should().Raise(nameof(PropTransferStore.Added)) .WithArgs <PropStoreEventArgs>(args => args.Props[0].Scheme == resource.Scheme); monitorContainer.Should().Raise(nameof(PropTransferStore.Removed)) .WithArgs <PropStoreEventArgs>(args => args.Props[0].Scheme == resource.Scheme); } }
public void TransferPropTest() { // ARRANGE var resourceScheme = new PropScheme(); // Инвентарь var inventory = new Inventory(); // контейнер var containerProps = new IProp[] { new Resource(resourceScheme, 1) }; var nodeMock = new Mock <IMapNode>(); var node = nodeMock.Object; var container = new FixedPropChest(node, containerProps); // трансферная машина var transferMachine = new PropTransferMachine(inventory, container.Content); // ACT var transferResource = new Resource(resourceScheme, 1); transferMachine.TransferProp(transferResource, transferMachine.Container, transferMachine.Inventory); // ASSERT transferMachine.Inventory.PropAdded[0].Should().BeOfType <Resource>(); var invResource = (Resource)transferMachine.Inventory.PropAdded[0]; invResource.Count.Should().Be(1); }