public void EquipTask_EquipedSlotAndFromSlot_PropEquipedInSlot() { // ARRANGE const int testedSlotIndex = 0; var propScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; var testedEquipmentProp = new Equipment(propScheme, new ITacticalActScheme[0], name: "tested"); var equipedEquipmentProp = new Equipment(propScheme, new ITacticalActScheme[0], name: "equiped"); var actorMock = new Mock <IActor>(); var actor = actorMock.Object; var personMock = new Mock <IPerson>(); var person = personMock.Object; actorMock.SetupGet(x => x.Person).Returns(person); var equipmentsInit = new Equipment[] { equipedEquipmentProp, testedEquipmentProp }; var equipmentCarrierMock = new Mock <EquipmentCarrierBase>(new object[] { equipmentsInit }) .As <IEquipmentCarrier>(); equipmentCarrierMock.CallBase = true; var equipmentCarrier = equipmentCarrierMock.Object; personMock.SetupGet(x => x.EquipmentCarrier).Returns(equipmentCarrier); var inventoryMock = new Mock <IPropStore>(); var inventory = inventoryMock.Object; personMock.SetupGet(x => x.Inventory).Returns(inventory); var task = new EquipTask(actor, testedEquipmentProp, testedSlotIndex); // ACT task.Execute(); // ASSERT equipmentCarrier[0].Should().BeSameAs(testedEquipmentProp); equipmentCarrier[1].Should().BeSameAs(equipedEquipmentProp); inventoryMock.Verify(x => x.Add(It.IsAny <IProp>()), Times.Never); inventoryMock.Verify(x => x.Remove(It.IsAny <IProp>()), Times.Never); }
public void EquipTask_EquipedSlotAndFromInventory_PropEquipedInSlot() { // ARRANGE const int testedSlotIndex = 0; var propScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; var testedEquipmentProp = new Equipment(propScheme, System.Array.Empty <ITacticalActScheme>()); var equipedEquipmentProp = new Equipment(propScheme, System.Array.Empty <ITacticalActScheme>()); var actorMock = new Mock <IActor>(); var actor = actorMock.Object; var personMock = new Mock <IPerson>(); var person = personMock.Object; actorMock.SetupGet(x => x.Person).Returns(person); var initEquipments = new Equipment[] { equipedEquipmentProp }; var equipmentCarrierMock = new Mock <EquipmentModuleBase>(new object[] { initEquipments }) .As <IEquipmentModule>(); equipmentCarrierMock.CallBase = true; var equipmentModule = equipmentCarrierMock.Object; personMock.Setup(x => x.GetModule <IEquipmentModule>(It.IsAny <string>())).Returns(equipmentModule); var inventoryMock = new Mock <IInventoryModule>(); var inventory = inventoryMock.Object; personMock.Setup(x => x.GetModule <IInventoryModule>(It.IsAny <string>())).Returns(inventory); var task = new EquipTask(actor, testedEquipmentProp, testedSlotIndex); // ACT task.Execute(); // ASSERT equipmentModule[0].Should().BeSameAs(testedEquipmentProp); inventoryMock.Verify(x => x.Remove(It.Is <IProp>(equipment => equipment == testedEquipmentProp)), Times.Once); inventoryMock.Verify(x => x.Add(It.Is <IProp>(equipment => equipment == equipedEquipmentProp)), Times.Once); }
public void EquipTask_EquipedSlotAndFromSlot_PropEquipedInSlot() { // ARRANGE const int testedSlotIndex = 0; var propScheme = new TestPropScheme { Equip = new TestPropEquipSubScheme() }; var testedEquipmentProp = new Equipment(propScheme, Array.Empty <ITacticalActScheme>(), name: "tested"); var equipedEquipmentProp = new Equipment(propScheme, Array.Empty <ITacticalActScheme>(), name: "equiped"); var actorMock = new Mock <IActor>(); var actor = actorMock.Object; var personMock = new Mock <IPerson>(); var person = personMock.Object; actorMock.SetupGet(x => x.Person).Returns(person); var equipmentsInit = new[] { equipedEquipmentProp, testedEquipmentProp }; var equipmentModuleMock = new Mock <EquipmentModuleBase>(new object[] { equipmentsInit }) .As <IEquipmentModule>(); equipmentModuleMock.CallBase = true; var equipmentModule = equipmentModuleMock.Object; personMock.Setup(x => x.GetModule <IEquipmentModule>(It.IsAny <string>())).Returns(equipmentModule); var inventoryMock = new Mock <IInventoryModule>(); var inventory = inventoryMock.Object; personMock.Setup(x => x.GetModule <IInventoryModule>(It.IsAny <string>())).Returns(inventory); var contextMock = new Mock <IActorTaskContext>(); var context = contextMock.Object; var task = new EquipTask(actor, context, testedEquipmentProp, testedSlotIndex); // ACT task.Execute(); // ASSERT equipmentModule[0].Should().BeSameAs(testedEquipmentProp); equipmentModule[1].Should().BeSameAs(equipedEquipmentProp); inventoryMock.Verify(x => x.Add(It.IsAny <IProp>()), Times.Never); inventoryMock.Verify(x => x.Remove(It.IsAny <IProp>()), Times.Never); }