Example #1
0
        public void IsComponentOverriding()
        {
            var pipeline = new TestBuildPipelineWithUsedComponents();
            var configB  = BuildConfiguration.CreateInstance(c => c.SetComponent <TestBuildComponentA>());
            var configA  = BuildConfiguration.CreateInstance(c =>
            {
                c.SetComponent <TestBuildComponentA>();
                c.SetComponent <TestBuildComponentB>();
                c.AddDependency(configB);
            });
            var context = new TestContextBase(pipeline, configA);

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

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