Beispiel #1
0
        public void GetComponentOrDefault()
        {
            var pipeline = new TestBuildPipelineWithUsedComponents();
            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)));
        }