Beispiel #1
0
        public void ScopedInputAnnotationWithSweepTest()
        {
            var sweepStep   = new SweepParameterStep();
            var verdictStep = new VerdictStep();

            sweepStep.ChildTestSteps.Add(verdictStep);
            var ifStep = new IfStep();

            sweepStep.ChildTestSteps.Add(ifStep);
            var member = TypeData.GetTypeData(ifStep).GetMember(nameof(IfStep.InputVerdict));
            var parameterizedMember = member.Parameterize(sweepStep, ifStep, member.Name);

            var annotation       = AnnotationCollection.Annotate(sweepStep);
            var memberAnnotation = annotation.GetMember(nameof(sweepStep.SweepValues));
            var col = memberAnnotation.Get <ICollectionAnnotation>();

            col.AnnotatedElements = new[] { col.NewElement() };
            annotation.Write();
            annotation.Read();
            var member2Annotation = col.AnnotatedElements.FirstOrDefault().GetMember(parameterizedMember.Name);
            var avail             = member2Annotation.Get <IAvailableValuesAnnotation>();

            Assert.IsNotNull(avail);

            // available values: None, verdict from itself, verdict from SetVerdict.

            Assert.AreEqual(3, avail.AvailableValues.Cast <object>().Count());
            var strings = avail.AvailableValues.Cast <object>().Select(x => x.ToString()).ToArray();

            Assert.IsTrue(strings.Contains($"Verdict from {ifStep.GetFormattedName()}"));
            Assert.IsTrue(strings.Contains("None"));
            Assert.IsTrue(strings.Contains($"Verdict from {verdictStep.GetFormattedName()}"));
        }
Beispiel #2
0
        public void ScopedInputAnnotationTest()
        {
            var seqStep     = new SequenceStep();
            var verdictStep = new VerdictStep();

            seqStep.ChildTestSteps.Add(verdictStep);
            var ifStep = new IfStep();

            seqStep.ChildTestSteps.Add(ifStep);
            var member = TypeData.GetTypeData(ifStep).GetMember(nameof(IfStep.InputVerdict));
            var parameterizedMember = member.Parameterize(seqStep, ifStep, member.Name);

            var annotation       = AnnotationCollection.Annotate(seqStep);
            var memberAnnotation = annotation.GetMember(parameterizedMember.Name);
            var avail            = memberAnnotation.Get <IAvailableValuesAnnotation>();

            Assert.IsNotNull(avail);

            // available values: None, verdict from itself, verdict from SetVerdict.

            Assert.AreEqual(3, avail.AvailableValues.Cast <object>().Count());
            var strings = avail.AvailableValues.Cast <object>().Select(x => x.ToString()).ToArray();

            Assert.IsTrue(strings.Contains($"Verdict from {ifStep.GetFormattedName()}"));
            Assert.IsTrue(strings.Contains("None"));
            Assert.IsTrue(strings.Contains($"Verdict from {verdictStep.GetFormattedName()}"));
        }