Exemplo n.º 1
0
        public void ResolveDependencies_PromisesReturnsNull_ThrowsArgumentNullException()
        {
            var accessor = new SubAccessor();

            var contract = new CompositionContract(typeof(int));

            AssertExtensions.Throws <ArgumentNullException>("source", () => accessor.ResolveDependencies("Site", contract, true));
            Assert.Same(contract, accessor.Contract);
        }
Exemplo n.º 2
0
        public void ResolveDependencies_PromisesReturnsNullObjectInArray_ThrowsArgumentNullException()
        {
            var accessor = new SubAccessor {
                Result = new ExportDescriptorPromise[] { null }
            };

            var contract = new CompositionContract(typeof(int));

            AssertExtensions.Throws <ArgumentNullException>("target", () => accessor.ResolveDependencies("Site", contract, true));
            Assert.Same(contract, accessor.Contract);
        }
Exemplo n.º 3
0
        public void ResolveDependencies_PromisesReturnsEmpty_ReturnsEmpty()
        {
            var accessor = new SubAccessor {
                Result = new ExportDescriptorPromise[0]
            };

            var contract = new CompositionContract(typeof(int));

            Assert.Empty(accessor.ResolveDependencies("Site", contract, true));
            Assert.Same(contract, accessor.Contract);
        }
Exemplo n.º 4
0
        public void ResolveDependencies_PromisesReturnsNonEmpty_ReturnsExpected()
        {
            var descriptor = ExportDescriptor.Create(Activator, new Dictionary <string, object>());
            var target     = new ExportDescriptorPromise(new CompositionContract(typeof(int)), "Origin", false, () => Enumerable.Empty <CompositionDependency>(), dependencies =>
            {
                return(ExportDescriptor.Create(Activator, new Dictionary <string, object>()));
            });
            var accessor = new SubAccessor {
                Result = new ExportDescriptorPromise[] { target }
            };

            var contract = new CompositionContract(typeof(int));
            CompositionDependency dependency = Assert.Single(accessor.ResolveDependencies("Site", contract, true));

            Assert.Same(contract, accessor.Contract);

            Assert.Same(contract, dependency.Contract);
            Assert.Equal("Site", dependency.Site);
            Assert.True(dependency.IsPrerequisite);
            Assert.Same(target, dependency.Target);
        }