예제 #1
0
        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>();
        }
예제 #2
0
        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_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));
                }
        }