コード例 #1
0
        public void GetOptionalComponent_WithMissingOptionalComponent_IsValid()
        {
            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.GetOptionalComponent <TestOptionalComponentA>(context), Is.Not.Null);
            Assert.That(step.GetOptionalComponent <TestOptionalComponentB>(context), Is.Not.Null);
        }
コード例 #2
0
        public void GetOptionalComponent_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.GetOptionalComponent <TestRequiredComponentA>(context));
            Assert.Throws <ArgumentNullException>(() => step.GetOptionalComponent(context, null));
            Assert.Throws <InvalidOperationException>(() => step.GetOptionalComponent(context, typeof(object)));
            Assert.Throws <InvalidOperationException>(() => step.GetOptionalComponent(context, typeof(TestInvalidComponent)));
        }