예제 #1
0
        public void TestMultipleOutputFromTheSameProperty()
        {
            var a            = new OutputInput();
            var b            = new OutputInput();
            var inputMember  = TypeData.GetTypeData(a).GetMember(nameof(a.Input));
            var outputMember = TypeData.GetTypeData(b).GetMember(nameof(b.Output));
            var inputMember2 = TypeData.GetTypeData(a).GetMember(nameof(a.ExpectedInput));

            InputOutputRelation.Assign(a, inputMember, b, outputMember);
            InputOutputRelation.Assign(a, inputMember2, b, outputMember);

            Assert.IsTrue(InputOutputRelation.IsInput(a, inputMember));
            Assert.IsTrue(InputOutputRelation.IsInput(a, inputMember2));
            Assert.Throws <ArgumentException>(() => InputOutputRelation.Assign(a, inputMember, b, outputMember));
            Assert.Throws <ArgumentException>(() => InputOutputRelation.Assign(a, inputMember2, b, outputMember));
        }
예제 #2
0
        public void TestMenuAnnotationForInputOutputRelations()
        {
            var userInput = UserInput.GetInterface();
            var request   = new SelectAssignmentFromAnnotationMenu();

            UserInput.SetInterface(request);
            try
            {
                var step1 = new OutputInput {
                    Output = 5, Input = 5, Name = "Step 1"
                };
                var step2 = new OutputInput {
                    ExpectedInput = 5, CheckExpectedInput = true, Name = "Step 2"
                };
                var step3 = new OutputInput {
                    ExpectedInput = 5, CheckExpectedInput = true, Name = "Step 3"
                };
                var plan = new TestPlan();
                plan.ChildTestSteps.AddRange(new[] { step1, step2, step3 });

                var menu = AnnotationCollection.Annotate(step2).GetMember(nameof(OutputInput.Input))
                           .Get <MenuAnnotation>();
                request.SelectName = "Step 1";
                menu.MenuItems.First(x => x.Get <IconAnnotationAttribute>().IconName == IconNames.AssignOutput).Get <IMethodAnnotation>().Invoke();
                request.SelectName = "Step 2";
                menu = AnnotationCollection.Annotate(step3).GetMember(nameof(OutputInput.Input))
                       .Get <MenuAnnotation>();
                menu.MenuItems.First(x => x.Get <IconAnnotationAttribute>().IconName == IconNames.AssignOutput).Get <IMethodAnnotation>().Invoke();

                var run = plan.Execute();
                Assert.AreEqual(Verdict.Pass, run.Verdict);
                Assert.IsTrue(request.WasInvoked);
            }
            finally
            {
                UserInput.SetInterface(userInput);
            }
        }
예제 #3
0
        public void TestSerializingConnectionsBetweenSteps()
        {
            var step1 = new OutputInput {
                Output = 5, Input = 5, Name = "Step 1"
            };
            var step2 = new OutputInput {
                ExpectedInput = 5, CheckExpectedInput = true, Name = "Step 2"
            };
            var step3 = new OutputInput {
                ExpectedInput = 5, CheckExpectedInput = true, Name = "Step 3"
            };
            var plan = new TestPlan();

            plan.ChildTestSteps.AddRange(new [] { step1, step2, step3 });
            var outputMember = TypeData.GetTypeData(step1).GetMember(nameof(OutputInput.Output));
            var inputMember  = TypeData.GetTypeData(step1).GetMember(nameof(OutputInput.Input));

            InputOutputRelation.Assign(step2, inputMember, step1, outputMember);
            InputOutputRelation.Assign(step3, inputMember, step2, outputMember);

            var xml = plan.SerializeToString();

            var plan2 = Utils.DeserializeFromString <TestPlan>(xml);

            step1 = (OutputInput)plan2.Steps[0];
            step2 = (OutputInput)plan2.Steps[1];
            step3 = (OutputInput)plan2.Steps[2];
            Assert.IsTrue(InputOutputRelation.IsOutput(step1, outputMember));
            Assert.IsFalse(InputOutputRelation.IsInput(step1, outputMember));
            Assert.IsFalse(InputOutputRelation.IsOutput(step1, inputMember));
            Assert.IsFalse(InputOutputRelation.IsInput(step1, inputMember));

            Assert.IsTrue(InputOutputRelation.IsInput(step2, inputMember));
            Assert.IsTrue(InputOutputRelation.IsOutput(step2, outputMember));
            Assert.IsTrue(InputOutputRelation.IsInput(step3, inputMember));
            Assert.IsFalse(InputOutputRelation.IsOutput(step3, outputMember));
        }
예제 #4
0
        public void TestInputOutputRelationsInTestPlan()
        {
            var step1 = new OutputInput {
                Output = 5, Input = 5, Name = "Step 1"
            };
            var step2 = new OutputInput {
                ExpectedInput = 5, CheckExpectedInput = true, Name = "Step 2"
            };
            var step3 = new OutputInput {
                ExpectedInput = 5, CheckExpectedInput = true, Name = "Step 3"
            };
            var plan = new TestPlan();

            plan.ChildTestSteps.AddRange(new [] { step1, step2, step3 });
            {
                var outputMember = TypeData.GetTypeData(step1).GetMember(nameof(OutputInput.Output));
                var inputMember  = TypeData.GetTypeData(step1).GetMember(nameof(OutputInput.Input));
                InputOutputRelation.Assign(step2, inputMember, step1, outputMember);
                InputOutputRelation.Assign(step3, inputMember, step2, outputMember);

                Assert.IsTrue(InputOutputRelation.IsOutput(step1, outputMember));
                Assert.IsFalse(InputOutputRelation.IsInput(step1, outputMember));
                Assert.IsFalse(InputOutputRelation.IsOutput(step1, inputMember));
                Assert.IsFalse(InputOutputRelation.IsInput(step1, inputMember));

                Assert.IsTrue(InputOutputRelation.IsInput(step2, inputMember));
                Assert.IsTrue(InputOutputRelation.IsOutput(step2, outputMember));
                Assert.IsTrue(InputOutputRelation.IsInput(step3, inputMember));
                Assert.IsFalse(InputOutputRelation.IsOutput(step3, outputMember));
            }

            {
                var run = plan.Execute();
                Assert.AreEqual(Verdict.Pass, run.Verdict);
            }
        }