Exemplo n.º 1
0
        public void HasOptionalComponent_WithMissingOptionalComponent_IsFalse()
        {
            var step     = new TestBuildStepWithRequirements();
            var pipeline = BuildPipeline.CreateInstance(p => p.BuildSteps.Add(step));
            var config   = BuildConfiguration.CreateInstance();
            var context  = new BuildContext(pipeline, config);

            Assert.That(step.HasOptionalComponent <TestOptionalComponentA>(context), Is.False);
            Assert.That(step.HasOptionalComponent <TestOptionalComponentB>(context), Is.False);
        }
Exemplo n.º 2
0
        public void HasOptionalComponent_WithInvalidType_Throws()
        {
            var step     = new TestBuildStepWithRequirements();
            var pipeline = BuildPipeline.CreateInstance(p => p.BuildSteps.Add(step));
            var config   = BuildConfiguration.CreateInstance();
            var context  = new BuildContext(pipeline, config);

            Assert.Throws <InvalidOperationException>(() => step.HasOptionalComponent <TestRequiredComponentA>(context));
            Assert.Throws <ArgumentNullException>(() => step.HasOptionalComponent(context, null));
            Assert.Throws <InvalidOperationException>(() => step.HasOptionalComponent(context, typeof(object)));
            Assert.Throws <InvalidOperationException>(() => step.HasOptionalComponent(context, typeof(TestInvalidComponent)));
        }
Exemplo n.º 3
0
        public void HasOptionalComponent_IsTrue()
        {
            var step     = new TestBuildStepWithRequirements();
            var pipeline = BuildPipeline.CreateInstance(p => p.BuildSteps.Add(step));
            var config   = BuildConfiguration.CreateInstance((c) =>
            {
                c.SetComponent(new TestOptionalComponentA());
                c.SetComponent(new TestOptionalComponentB());
            });
            var context = new BuildContext(pipeline, config);

            Assert.That(step.HasOptionalComponent <TestOptionalComponentA>(context), Is.True);
            Assert.That(step.HasOptionalComponent <TestOptionalComponentB>(context), Is.True);
        }