Пример #1
0
        public void TestPostActionConditioning(bool condition1, bool condition2, int expectedActionCount, string[] firstResult, string[] secondResult)
        {
            SimpleConfigModel   configModel = SimpleConfigModel.FromJObject(TestTemplateJson);
            IVariableCollection vc          = new VariableCollection
            {
                ["ActionOneCondition"] = condition1,
                ["ActionTwoCondition"] = condition2
            };
            List <IPostAction> postActions = PostAction.ListFromModel(_logger, configModel.PostActionModels, vc);

            Assert.Equal(expectedActionCount, postActions.Count);
            if (firstResult != null && firstResult.Length > 0)
            {
                Assert.True(string.Equals(postActions[0].Description, firstResult[0]), $"expected '{firstResult[0]}', but got {postActions[0].Description}");
                Assert.Equal(firstResult[1], postActions[0].ManualInstructions);
            }

            if (secondResult != null && secondResult.Length > 0)
            {
                Assert.True(string.Equals(postActions[1].Description, secondResult[0]), $"expected '{secondResult[0]}', but got {postActions[1].Description}");
                Assert.Equal(secondResult[1], postActions[1].ManualInstructions);
            }
        }
Пример #2
0
        public void TestPostActionInstructionsConditioning(bool condition1, bool condition2, int expectedActionCount, string operatingSystemValue, string firstInstruction, string secondInstruction)
        {
            SimpleConfigModel   configModel = SimpleConfigModel.FromJObject(TestTemplateJson);
            IVariableCollection vc          = new VariableCollection
            {
                ["ActionOneCondition"]  = condition1,
                ["ActionTwoCondition"]  = condition2,
                ["OperatingSystemKind"] = operatingSystemValue
            };

            List <IPostAction> postActions = PostAction.ListFromModel(_logger, configModel.PostActionModels, vc);

            Assert.Equal(expectedActionCount, postActions.Count);

            if (!string.IsNullOrEmpty(firstInstruction))
            {
                Assert.Equal(firstInstruction, postActions[0].ManualInstructions);
            }

            if (!string.IsNullOrEmpty(secondInstruction))
            {
                Assert.Equal(secondInstruction, postActions[1].ManualInstructions);
            }
        }