コード例 #1
0
        public void CanBuild_WithComponents_IsTrue()
        {
            var pipeline = new TestBuildPipelineWithComponents();
            var config   = BuildConfiguration.CreateInstance();

            Assert.That(pipeline.CanBuild(config).Result, Is.True);
        }
コード例 #2
0
        public void Run_WithComponents_Succeeds()
        {
            var pipeline = new TestBuildPipelineWithComponents();
            var config   = BuildConfiguration.CreateInstance();

            Assert.That(pipeline.Build(config).Succeeded, Is.True);
            Assert.That(pipeline.CanRun(config).Result, Is.True);
            using (var result = pipeline.Run(config))
            {
                Assert.That(result.Succeeded, Is.True);
            }
        }
コード例 #3
0
        public void GetComponentOrDefault()
        {
            var pipeline = new TestBuildPipelineWithComponents();
            var config   = BuildConfiguration.CreateInstance();
            var context  = new TestContextBase(pipeline, config);

            Assert.That(context.HasComponent <TestBuildComponentA>(), Is.False);
            Assert.That(context.GetComponentOrDefault <TestBuildComponentA>(), Is.Not.Null);
            Assert.Throws <InvalidOperationException>(() => context.GetComponentOrDefault <TestBuildComponentC>());
            Assert.Throws <ArgumentNullException>(() => context.GetComponentOrDefault(null));
            Assert.Throws <InvalidOperationException>(() => context.GetComponentOrDefault(typeof(object)));
            Assert.Throws <InvalidOperationException>(() => context.GetComponentOrDefault(typeof(TestBuildComponentInvalid)));
        }
コード例 #4
0
        public void TryGetComponent()
        {
            var pipeline = new TestBuildPipelineWithComponents();
            var config   = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentA>());
            var context  = new TestContextBase(pipeline, config);

            Assert.That(context.TryGetComponent <TestBuildComponentA>(out _), Is.True);
            Assert.That(context.TryGetComponent <TestBuildComponentB>(out _), Is.False);
            Assert.Throws <InvalidOperationException>(() => context.TryGetComponent <TestBuildComponentC>(out _));
            Assert.Throws <ArgumentNullException>(() => context.TryGetComponent(null, out _));
            Assert.Throws <InvalidOperationException>(() => context.TryGetComponent(typeof(object), out _));
            Assert.Throws <InvalidOperationException>(() => context.TryGetComponent(typeof(TestBuildComponentInvalid), out _));
        }
コード例 #5
0
        public void BuildIncremental_WithComponents_Succeeds()
        {
            var pipeline = new TestBuildPipelineWithComponents();
            var config   = BuildConfiguration.CreateInstance();

            Assert.That(pipeline.CanBuild(config).Result, Is.True);
            using (var process = pipeline.BuildIncremental(config))
            {
                while (process.Update())
                {
                }
                Assert.That(process.Result.Succeeded, Is.True);
            }
        }
コード例 #6
0
        public void GetComponentTypes()
        {
            var pipeline = new TestBuildPipelineWithComponents();
            var configB  = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentB>());
            var configA  = BuildConfiguration.CreateInstance(c =>
            {
                c.SetComponent <TestBuildComponentA>();
                c.AddDependency(configB);
            });
            var context = new TestContextBase(pipeline, configA);

            Assert.That(context.GetComponentTypes(), Is.EquivalentTo(new[] { typeof(TestBuildComponentA), typeof(TestBuildComponentB) }));

            configA.SetComponent <TestBuildComponentC>();
            Assert.Throws <InvalidOperationException>(() => context.GetComponentTypes());
        }
コード例 #7
0
        public void IsComponentInherited()
        {
            var pipeline = new TestBuildPipelineWithComponents();
            var configB  = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentB>());
            var configA  = BuildConfiguration.CreateInstance(c =>
            {
                c.SetComponent <TestBuildComponentA>();
                c.AddDependency(configB);
            });
            var context = new TestContextBase(pipeline, configA);

            Assert.That(context.IsComponentInherited <TestBuildComponentA>(), Is.False);
            Assert.That(context.IsComponentInherited <TestBuildComponentB>(), Is.True);
            Assert.Throws <InvalidOperationException>(() => context.IsComponentInherited <TestBuildComponentC>());

            Assert.Throws <ArgumentNullException>(() => context.IsComponentInherited(null));
            Assert.Throws <InvalidOperationException>(() => context.IsComponentInherited(typeof(object)));
            Assert.Throws <InvalidOperationException>(() => context.IsComponentInherited(typeof(TestBuildComponentInvalid)));
        }