public void TestInvalidDependencyType()
        {
            var    build  = new InvalidDependencyTypeTestBuild();
            Action action = () => ExecutableTargetFactory.CreateAll(build, x => x.E);

            action.Should().Throw <InvalidCastException>();
        }
Example #2
0
        public void TestInheritance()
        {
            var build   = new TestFinalBuild();
            var targets = ExecutableTargetFactory.CreateAll(build);

            var shared       = targets.Should().ContainSingle(x => x.Name == nameof(TestFinalBuild.SharedTarget)).Subject;
            var override_    = targets.Should().ContainSingle(x => x.Name == nameof(TestFinalBuild.SpecificTarget)).Subject;
            var explicitBase = targets.Should().ContainSingle(x => x.Name == nameof(ITestSharedBuild.ExplicitSharedTarget)).Subject;
            var explicit_    = targets.Should().ContainSingle(x => x.Name == nameof(IAnotherSharedBuild.ExplicitTarget)).Subject;

            shared.Actions.Should().HaveCount(1);
            shared.ExecutionDependencies.Single().Name.Should().Be(nameof(TestFinalBuild.SpecificTarget));
            shared.Description.Should().Be(nameof(TestFinalBuild.SharedTarget));

            override_.Actions.Should().HaveCount(1);
            override_.OrderDependencies.Single().Name.Should().Be(nameof(TestFinalBuild.SharedTarget));
            override_.Description.Should().Be(nameof(TestFinalBuild.SpecificTarget));

            targets.Should().HaveCount(8);
            targets.Single(x => x.Name == nameof(ITestSharedBuild.AbstractSharedTarget)).Description.Should().Be("RIGHT");
            targets.Single(x => x.Name == nameof(ITestSharedBuild.ExplicitSharedTarget)).Description.Should().Be("RIGHT");
            targets.Single(x => x.Name == nameof(IAnotherSharedBuild.ExplicitTargetWithDefault)).Description.Should().Be("RIGHT");
            targets.Single(x => x.Name == nameof(IAnotherSharedBuild.ExplicitTargetWithoutDefault)).Description.Should().Be("RIGHT");
            targets.Single(x => x.Name == nameof(IAnotherSharedBuild.TargetWithDefault)).Description.Should().Be("RIGHT");
        }
        public void TestOverriddenDuplicatedTarget()
        {
            var build   = new OverriddenDuplicatedTargetTestBuild();
            var targets = ExecutableTargetFactory.CreateAll(build);

            targets.Count(x => x.Name == nameof(ITestBuild.D)).Should().Be(1);
        }
        public void TestDeclaringAndImplementingComponent()
        {
            var build   = new TestBuildWithDeclaringAndImplementingComponent();
            var targets = ExecutableTargetFactory.CreateAll(build);

            targets.Should().HaveCount(1);
            targets.Single().Member.DeclaringType.Should().Be(typeof(IImplementingComponent));
        }
        public void TestDuplicatedTarget()
        {
            var    build  = new DuplicatedTargetTestBuild();
            Action action = () => ExecutableTargetFactory.CreateAll(build);

            action.Should().Throw <Exception>().And.Message.Should()
            .StartWith("Property 'D' must be implemented explicitly because it is inherited from multiple interfaces");
        }
        public void TestNonPublicTarget()
        {
            var    build  = new NonPublicTargetTestBuild();
            Action action = () => ExecutableTargetFactory.CreateAll(build);

            action.Should().Throw <Exception>().And.Message.Should()
            .StartWith("Property 'D' must be marked public to override inherited member from:");
        }
Example #7
0
        public void TestNonPublicTarget()
        {
            var build     = new NonPublicTargetTestBuild();
            var exception = Assert.Throws <Exception>(() => ExecutableTargetFactory.CreateAll(build));

            exception.Message.Should()
            .StartWith("Assertion failed: Target 'D' must be marked public to override inherited member from:");
        }
Example #8
0
        public void TestDuplicatedTarget()
        {
            var build     = new DuplicatedTargetTestBuild();
            var exception = Assert.Throws <Exception>(() => ExecutableTargetFactory.CreateAll(build));

            exception.Message.Should()
            .StartWith("Assertion failed: Target 'D' must be implemented explicitly because it is inherited from multiple interfaces");
        }
        public void TestRequirementValidation()
        {
            EnvironmentInfo.SetVariable("StringParameter", "hello");
            var build   = new ParameterBuild();
            var targets = ExecutableTargetFactory.CreateAll(build, x => ((IParameterInterface)x).HelloWorld);

            // must not throw
            RequirementService.ValidateRequirements(build, targets);
        }
Example #10
0
        public Task Test(string testName, ITestConfigurationGenerator attribute)
        {
            var build           = new TestBuild();
            var relevantTargets = ExecutableTargetFactory.CreateAll(build, x => x.Compile);

            var stream = new MemoryStream();

            attribute.Stream = new StreamWriter(stream, leaveOpen: true);
            attribute.Generate(build, relevantTargets);

            stream.Seek(offset: 0, SeekOrigin.Begin);
            var reader = new StreamReader(stream);
            var str    = reader.ReadToEnd();

            return(Verifier.Verify(str)
                   .UseParameters(testName, attribute.GetType().BaseType.NotNull().Name));
        }
        public void TestMultipleInheritance()
        {
            var build   = new MultipleInheritanceTestBuild();
            var targets = ExecutableTargetFactory.CreateAll(build, x => x.Default);

            var a = targets.Single(x => x.Name == nameof(ITestBuild.A));
            var b = targets.Single(x => x.Name == nameof(ITestBuild.B));
            var c = targets.Single(x => x.Name == nameof(ITestBuild.C));
            var d = targets.Single(x => x.Name == nameof(ITestBuild.D));
            var f = targets.Single(x => x.Name == nameof(IInheritedTestBuild.F));

            f.Triggers.Should().Equal(a);

            b.DependencyBehavior.Should().Be(DependencyBehavior.Execute);
            b.StaticConditions.Should().Equal(StaticCondition);
            b.ExecutionDependencies.Should().Equal(d);
            b.TriggerDependencies.Should().Equal(c);
            b.AllDependencies.Should().NotBeEmpty();
        }
Example #12
0
        public void Test(string testName, ITestConfigurationGenerator attribute)
        {
            var build           = new TestBuild();
            var relevantTargets = ExecutableTargetFactory.CreateAll(build, x => x.Compile);

            var stream = new MemoryStream();

            attribute.Stream = new StreamWriter(stream, leaveOpen: true);
            attribute.Generate(build, relevantTargets);

            stream.Seek(offset: 0, SeekOrigin.Begin);
            var reader = new StreamReader(stream);
            var str    = reader.ReadToEnd();

            NamerFactory.AdditionalInformation = attribute.GetType().BaseType.NotNull().Name;
            if (testName != null)
            {
                NamerFactory.AdditionalInformation += "." + testName;
            }
            Approvals.Verify(str);
        }
        public void Test()
        {
            var build   = new TestBuild();
            var targets = ExecutableTargetFactory.CreateAll(build, x => x.E);

            var a = targets.Single(x => x.Name == nameof(ITestBuild.A));
            var b = targets.Single(x => x.Name == nameof(ITestBuild.B));
            var c = targets.Single(x => x.Name == nameof(ITestBuild.C));
            var d = targets.Single(x => x.Name == nameof(ITestBuild.D));
            var e = targets.Single(x => x.Name == nameof(TestBuild.E));

            targets.Single(x => x.IsDefault).Should().Be(e);

            a.Description.Should().Be(Description);
            a.Requirements.Should().Equal(Requirement);
            a.Actions.Should().Equal(Action);
            a.AllDependencies.Should().BeEmpty();

            b.DependencyBehavior.Should().Be(DependencyBehavior.Execute);
            b.StaticConditions.Should().Equal(StaticCondition);
            b.ExecutionDependencies.Should().Equal(d);
            b.TriggerDependencies.Should().Equal(c);
            b.AllDependencies.Should().NotBeEmpty();

            c.Triggers.Should().Equal(b);
            c.TriggerDependencies.Should().Equal(d);
            c.ExecutionDependencies.Should().Equal(b);
            c.OrderDependencies.Should().Equal(d);
            c.AllDependencies.Should().NotBeEmpty();

            d.DependencyBehavior.Should().Be(DependencyBehavior.Skip);
            d.DynamicConditions.Should().Equal(DynamicCondition);
            d.OrderDependencies.Should().Equal(b);
            d.Triggers.Should().Equal(c);
            d.AllDependencies.Should().NotBeEmpty();

            e.ExecutionDependencies.Should().Equal(a);
        }
Example #14
0
        public void TestInvalidDependencyType()
        {
            var build = new InvalidDependencyTypeTestBuild();

            Assert.Throws <InvalidCastException>(() => ExecutableTargetFactory.CreateAll(build, x => x.E));
        }