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