public void CanFindSystemTypeAndCachesTypeFound()
 {
     Stub.On(dataTypeFactory).Method("Create").With(typeof(Int32)).Will(Return.Value(dataType));
     ITypeFinder finder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache, typeFinder, dataTypeFactory);
     Expect.Once.On(typesCache).Method("Add").With("System.Int32", typeof (Int32));
     Assert.AreSame(dataType, finder.GetType("System.Int32"));
 }
        public void CanFindArrayType()
        {
            Stub.On(dataTypeFactory).Method("Create").With(typeof(TestTypeA1[])).Will(Return.Value(dataType));
            Stub.On(dataType).GetProperty("IsArray").Will(Return.Value(true));
            Stub.On(typesCache).Method("Add").WithAnyArguments();

            ITypeFinder finder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache, typeFinder, dataTypeFactory);

            var type = finder.GetType("NSerializer.TestAssembly1.TestTypeA1[]");
            Assert.IsNotNull(type);
            Assert.IsTrue(type.IsArray);
        }
        public DefaultTypeFinder(Assembly seedAssembly, IDataTypeFactory dataTypeFactory)
        {
            var typeFinderConduit = new TypeFinderConduit();

            var typesCache = new CachedTypesFinder(dataTypeFactory);
            ITypeFinder genericTypeFinder = new GenericTypeFinder(typesCache, typeFinderConduit, dataTypeFactory);
            ITypeFinder typeInAssemblyFinder = new TypeInAssemblyFinder(seedAssembly, typesCache, dataTypeFactory);
            ITypeFinder typeInReferencedAssemblyFinder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache,
                                                                                            typeFinder, dataTypeFactory);

            typeFinder =
                new TypeFinder(typesCache, genericTypeFinder, typeInAssemblyFinder, typeInReferencedAssemblyFinder);

            typeFinderConduit.SetTarget(typeFinder);
        }
Beispiel #4
0
        public DefaultTypeFinder(Assembly seedAssembly, IDataTypeFactory dataTypeFactory)
        {
            var typeFinderConduit = new TypeFinderConduit();

            var         typesCache                     = new CachedTypesFinder(dataTypeFactory);
            ITypeFinder genericTypeFinder              = new GenericTypeFinder(typesCache, typeFinderConduit, dataTypeFactory);
            ITypeFinder typeInAssemblyFinder           = new TypeInAssemblyFinder(seedAssembly, typesCache, dataTypeFactory);
            ITypeFinder typeInReferencedAssemblyFinder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache,
                                                                                            typeFinder, dataTypeFactory);

            typeFinder =
                new TypeFinder(typesCache, genericTypeFinder, typeInAssemblyFinder, typeInReferencedAssemblyFinder);

            typeFinderConduit.SetTarget(typeFinder);
        }
        public void SetUp()
        {
            var dataTypeFactory = new DataTypeFactory();
            var seedAssembly = GetType().Assembly;

            var typeFinderConduit = new TypeFinderConduit();

            var typesCache = new CachedTypesFinder(dataTypeFactory);
            ITypeFinder genericTypeFindeer = new GenericTypeFinder(typesCache, typeFinderConduit, dataTypeFactory);
            ITypeFinder typeInAssemblyFinder = new TypeInAssemblyFinder(seedAssembly, typesCache, dataTypeFactory);
            ITypeFinder typeInReferencedAssembliesFinder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache, typeFinder, dataTypeFactory);

            typeFinder = new TypeFinder(typesCache, genericTypeFindeer, typeInAssemblyFinder,
                                        typeInReferencedAssembliesFinder);
            typeFinderConduit.SetTarget(typeFinder);
        }
 public void CanFindTypeInSecondReferencedAssembly()
 {
     Stub.On(dataTypeFactory).Method("Create").WithAnyArguments().Will(Return.Value(dataType));
     Stub.On(typesCache).Method("Add").WithAnyArguments();
     ITypeFinder finder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache, typeFinder, dataTypeFactory);
     Assert.AreSame(dataType, finder.GetType("NSerializer.TestAssembly2.TestTypeA2"));
 }
        private void CanFindType(Type soughtType)
        {
            Stub.On(dataTypeFactory).Method("Create").With(soughtType).Will(Return.Value(dataType));
            Stub.On(typesCache).Method("Add").WithAnyArguments();

            ITypeFinder finder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache, typeFinder, dataTypeFactory);

            Assert.AreSame(dataType, finder.GetType(soughtType.FullName));
        }
 public void DoesNotFindTypeInSeedAssembly()
 {
     Stub.On(dataTypeFactory).Method("Create").With(Is.Null).Will(Return.Value(dataType));
     ITypeFinder finder = new TypeInReferencedAssemblyFinder(seedAssembly, typesCache, typeFinder, dataTypeFactory);
     finder.GetType(GetType().FullName);
 }