示例#1
0
        public void GetRequiredComponent_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.GetRequiredComponent <TestRequiredComponentA>(context));
            Assert.Throws <InvalidOperationException>(() => step.GetRequiredComponent <TestRequiredComponentB>(context));
        }
示例#2
0
        public void GetRequiredComponent_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.GetRequiredComponent <TestOptionalComponentA>(context));
            Assert.Throws <ArgumentNullException>(() => step.GetRequiredComponent(context, null));
            Assert.Throws <InvalidOperationException>(() => step.GetRequiredComponent(context, typeof(object)));
            Assert.Throws <InvalidOperationException>(() => step.GetRequiredComponent(context, typeof(TestInvalidComponent)));
        }
示例#3
0
        public void GetRequiredComponent_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.GetRequiredComponent <TestRequiredComponentA>(context), Is.Not.Null);
            Assert.That(step.GetRequiredComponent <TestRequiredComponentB>(context), Is.Not.Null);
        }