Exemplo n.º 1
0
        public void GetOptionalComponents_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.GetOptionalComponents(context).Select(c => c.GetType()), Is.EquivalentTo(new[] { typeof(TestOptionalComponentA), typeof(TestOptionalComponentB) }));
            Assert.That(step.GetOptionalComponents <TestOptionalComponentA>(context).Select(c => c.GetType()), Is.EquivalentTo(new[] { typeof(TestOptionalComponentA) }));
            Assert.That(step.GetOptionalComponents <TestOptionalComponentB>(context).Select(c => c.GetType()), Is.EquivalentTo(new[] { typeof(TestOptionalComponentB) }));
        }
Exemplo n.º 2
0
        public void GetOptionalComponents_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.GetOptionalComponents <TestRequiredComponentA>(context));
            Assert.Throws <ArgumentNullException>(() => step.GetOptionalComponents(context, null));
            Assert.Throws <InvalidOperationException>(() => step.GetOptionalComponents(context, typeof(object)));
            Assert.Throws <InvalidOperationException>(() => step.GetOptionalComponents(context, typeof(TestInvalidComponent)));
        }