Exemple #1
0
        public void GetRequiredComponents_WithMissingRequiredComponent_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.GetRequiredComponents(context));
            Assert.Throws <InvalidOperationException>(() => step.GetRequiredComponents <TestRequiredComponentA>(context));
            Assert.Throws <InvalidOperationException>(() => step.GetRequiredComponents <TestRequiredComponentB>(context));
        }
Exemple #2
0
        public void GetRequiredComponents_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.GetRequiredComponents <TestOptionalComponentA>(context));
            Assert.Throws <ArgumentNullException>(() => step.GetRequiredComponents(context, null));
            Assert.Throws <InvalidOperationException>(() => step.GetRequiredComponents(context, typeof(object)));
            Assert.Throws <InvalidOperationException>(() => step.GetRequiredComponents(context, typeof(TestInvalidComponent)));
        }
Exemple #3
0
        public void GetRequiredComponents_IsValid()
        {
            var step     = new TestBuildStepWithRequirements();
            var pipeline = BuildPipeline.CreateInstance(p => p.BuildSteps.Add(step));
            var config   = BuildConfiguration.CreateInstance((c) =>
            {
                c.SetComponent(new TestRequiredComponentA());
                c.SetComponent(new TestRequiredComponentB());
            });
            var context = new BuildContext(pipeline, config);

            Assert.That(step.GetRequiredComponents(context).Select(c => c.GetType()), Is.EquivalentTo(new[] { typeof(TestRequiredComponentA), typeof(TestRequiredComponentB) }));
            Assert.That(step.GetRequiredComponents <TestRequiredComponentA>(context).Select(c => c.GetType()), Is.EquivalentTo(new[] { typeof(TestRequiredComponentA) }));
            Assert.That(step.GetRequiredComponents <TestRequiredComponentB>(context).Select(c => c.GetType()), Is.EquivalentTo(new[] { typeof(TestRequiredComponentB) }));
        }