public void IfCraftingStepTrueConditionTest()
        {
            Mock <ICraftingStep> mockChildStep = new Mock <ICraftingStep>();

            List <ICraftingStep> craftingSteps = new List <ICraftingStep>();
            IfCraftingStep       ifStep        = new IfCraftingStep();

            ifStep.Children.Add(mockChildStep.Object);
            ifStep.Condition = GetTestCondition();
            craftingSteps.Add(ifStep);

            EndCraftingStep endCrafting = new EndCraftingStep();

            craftingSteps.Add(endCrafting);

            Equipment    equipment    = GetTestEquipment(true);
            AffixManager affixManager = CreateAffixManager(equipment.ItemBase);

            CancellationToken token = new CancellationToken(false);

            mockChildStep.Setup(x => x.ShouldVisitChildren(It.IsAny <Equipment>(), It.IsAny <int>())).Returns(false);

            mockChildStep.Setup(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>()))
            .Returns(new Dictionary <string, int>());

            _craftManager.Craft(craftingSteps, equipment, affixManager, token, _progressManager);

            mockChildStep.Verify(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>()), Times.Once);

            Assert.IsTrue(equipment.Completed);
        }
        public void CurrencyCraftingTest()
        {
            Mock <ICraftingStep> mockChildStep = new Mock <ICraftingStep>();

            List <ICraftingStep> craftingSteps = new List <ICraftingStep>();
            WhileCraftingStep    whileStep     = new WhileCraftingStep();

            whileStep.Children.Add(mockChildStep.Object);
            whileStep.Condition = GetTestCondition();
            craftingSteps.Add(whileStep);

            EndCraftingStep endCrafting = new EndCraftingStep();

            craftingSteps.Add(endCrafting);

            Equipment    equipment    = GetTestEquipment(false);
            AffixManager affixManager = CreateAffixManager(equipment.ItemBase);

            CancellationToken token = new CancellationToken(false);

            _craftManager.Craft(craftingSteps, equipment, affixManager, token, _progressManager);

            mockChildStep.Verify(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>()), Times.Never);

            Assert.IsTrue(equipment.Completed);
        }
Beispiel #3
0
        public void EndCraftingStepsTest()
        {
            List <ICraftingStep> craftingSteps = new List <ICraftingStep>();
            EndCraftingStep      endStep       = new EndCraftingStep();

            craftingSteps.Add(endStep);

            StatusMetadata metadata = _statusManager.Evaluate(craftingSteps);

            Assert.IsTrue(metadata.CurrentStatus.Completed);
        }
        public void EndCraftingStepTest()
        {
            List <ICraftingStep> craftingSteps = new List <ICraftingStep>();
            EndCraftingStep      endCrafting   = new EndCraftingStep();

            craftingSteps.Add(endCrafting);

            Equipment         equipment    = GetTestEquipment(true);
            AffixManager      affixManager = CreateAffixManager(equipment.ItemBase);
            CancellationToken token        = new CancellationToken(false);

            _craftManager.Craft(craftingSteps, equipment, affixManager, token, _progressManager);

            Assert.IsTrue(equipment.Completed);
        }
        public void WhileCraftingStepFourTimesConditionTest()
        {
            Mock <ICraftingStep> mockChildStep = new Mock <ICraftingStep>();

            List <ICraftingStep> craftingSteps = new List <ICraftingStep>();
            WhileCraftingStep    whileStep     = new WhileCraftingStep();

            whileStep.Children.Add(mockChildStep.Object);
            whileStep.Condition = GetTestCondition();
            craftingSteps.Add(whileStep);

            EndCraftingStep endCrafting = new EndCraftingStep();

            craftingSteps.Add(endCrafting);

            Equipment    equipment    = GetTestEquipment(true);
            AffixManager affixManager = CreateAffixManager(equipment.ItemBase);

            CancellationToken token = new CancellationToken(false);

            int calls = 0;

            mockChildStep.Setup(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>()))
            .Returns(new Dictionary <string, int>()
            {
                { "TestCurrency", 1 }
            })
            .Callback(() =>
            {
                if (calls >= 3)
                {
                    UpdateEquipment(equipment, false);
                }

                calls++;
            });


            mockChildStep.Setup(x => x.ShouldVisitChildren(It.IsAny <Equipment>(), It.IsAny <int>())).Returns(false);

            _craftManager.Craft(craftingSteps, equipment, affixManager, token, _progressManager);

            mockChildStep.Verify(x => x.Craft(It.IsAny <Equipment>(), It.IsAny <AffixManager>()), Times.Exactly(4));

            Assert.IsTrue(equipment.Completed);
        }