Esempio n. 1
0
        public void WhereIsTypeWithExport_ShouldFindTwoParts()
        {
            var ctx = new RegistrationBuilder();

            ctx.ForTypesMatching((t) => { return(t.IsAssignableFrom(typeof(FooImplementation1))); }).Export();                   // Implements<FooImplementation1>
            ctx.ForTypesMatching((t) => { return(t.IsAssignableFrom(typeof(FooImplementation2))); }).Export();                   // Implements<FooImplementation2>
            var catalog = new TypeCatalog(Helpers.GetEnumerableOfTypes(typeof(IFoo), typeof(FooImplementation1), typeof(FooImplementation2)), ctx);

            Assert.IsTrue(catalog.Parts.Count() == 2);
        }
Esempio n. 2
0
        public void WhereIsClassAndImplementsIFooNoExport_ShouldFindZeroParts()
        {
            var ctx = new RegistrationBuilder();

            ctx.ForTypesMatching((t) => { return(t.IsClass && typeof(IFoo).IsAssignableFrom(t)); });                       // Implements<IFoo>
            var catalog = new TypeCatalog(Helpers.GetEnumerableOfTypes(typeof(IFoo), typeof(FooImplementation1), typeof(FooImplementation2)), ctx);

            Assert.IsTrue(catalog.Parts.Count() == 0);
        }
Esempio n. 3
0
 public void WhereNullArgument_ShouldThrowArgumentException()
 {
     ExceptionAssert.ThrowsArgument <ArgumentNullException>("typeFilter", () =>
     {
         var ctx = new RegistrationBuilder();
         ctx.ForTypesMatching(null);
         var catalog = new TypeCatalog(Helpers.GetEnumerableOfTypes(typeof(IFoo), typeof(FooImplementation1), typeof(FooImplementation2)), ctx);
         Assert.IsTrue(catalog.Parts.Count() == 0);
     });
 }