コード例 #1
0
        public void ReflectWhereSelectIterator()
        {
            IUnityContainer   container = GetContainer();
            IEnumerable <int> it = new List <int> {
                1, 2, 3
            }.Where(i => i == 2).Select(i => i);

            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { it.GetType().GetGenericTypeDefinition(), typeof(Object) }, new Type[] { }, new string[] { });

            rc.SupportedSystemTypes.Clear();

            container.RegisterInstance <IReflectorConfiguration>(rc);

            var reflector = container.Resolve <IReflector>();

            reflector.Reflect();
            var specs = reflector.AllObjectSpecImmutables;

            Assert.AreEqual(2, specs.Length);

            AbstractReflectorTest.AssertSpec(typeof(object), specs[0]);
            AbstractReflectorTest.AssertSpec(it.GetType().GetGenericTypeDefinition(), specs[1]);
        }
コード例 #2
0
        public void ReflectInt()
        {
            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { typeof(int) }, new Type[] { }, new[] { "System" });

            rc.SupportedSystemTypes.Clear();

            var container = GetContainer(rc);

            var reflector = container.GetService <IReflector>();

            reflector.Reflect();

            var specs = reflector.AllObjectSpecImmutables;

            Assert.AreEqual(8, specs.Length);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <int>), specs);
            AbstractReflectorTest.AssertSpec(typeof(int), specs);
            AbstractReflectorTest.AssertSpec(typeof(IConvertible), specs);
            AbstractReflectorTest.AssertSpec(typeof(object), specs);
            AbstractReflectorTest.AssertSpec(typeof(ValueType), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable <int>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable), specs);
            AbstractReflectorTest.AssertSpec(typeof(IFormattable), specs);
        }
コード例 #3
0
        public void ReflectQueryableTypes()
        {
            IUnityContainer     container = GetContainer();
            IQueryable <object> qo        = new List <object>().AsQueryable();
            IQueryable <int>    qi        = new List <int>().AsQueryable();

            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { qo.GetType(), qi.GetType(), typeof(int), typeof(object) }, new Type[] { }, new string[] { });

            rc.SupportedSystemTypes.Clear();

            container.RegisterInstance <IReflectorConfiguration>(rc);

            var reflector = container.Resolve <IReflector>();

            reflector.Reflect();
            var specs = reflector.AllObjectSpecImmutables;

            Assert.AreEqual(3, specs.Length);

            AbstractReflectorTest.AssertSpec(typeof(int), specs[0]);
            AbstractReflectorTest.AssertSpec(typeof(object), specs[1]);
            AbstractReflectorTest.AssertSpec(typeof(EnumerableQuery <>), specs[2]);
        }
コード例 #4
0
        public void ReflectByteArray()
        {
            IUnityContainer container = GetContainer();

            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { typeof(TestObjectWithByteArray) }, new Type[] { }, new[] { "System" });

            rc.SupportedSystemTypes.Clear();

            container.RegisterInstance <IReflectorConfiguration>(rc);

            var reflector = container.Resolve <IReflector>();

            reflector.Reflect();

            var specs = reflector.AllObjectSpecImmutables;

            //Assert.AreEqual(31, specs.Length);

            AbstractReflectorTest.AssertSpec(typeof(IList), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <long>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <int>), specs);
            AbstractReflectorTest.AssertSpec(typeof(int), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable <byte>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IConvertible), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <byte>), specs);
            AbstractReflectorTest.AssertSpec(typeof(object), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable <bool>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <bool>), specs);
            AbstractReflectorTest.AssertSpec(typeof(byte[]), specs);
            AbstractReflectorTest.AssertSpec(typeof(Array), specs);
            AbstractReflectorTest.AssertSpec(typeof(ValueType), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable <long>), specs);
            AbstractReflectorTest.AssertSpec(typeof(long), specs);
            AbstractReflectorTest.AssertSpec(typeof(IStructuralComparable), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable), specs);
            AbstractReflectorTest.AssertSpec(typeof(ICollection), specs);
            AbstractReflectorTest.AssertSpec(typeof(bool), specs);
            AbstractReflectorTest.AssertSpec(typeof(ICloneable), specs);
            AbstractReflectorTest.AssertSpec(typeof(IList <>), specs);
            AbstractReflectorTest.AssertSpec(typeof(byte), specs);
            AbstractReflectorTest.AssertSpec(typeof(IFormattable), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable <int>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IReadOnlyList <>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IReadOnlyCollection <>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IStructuralEquatable), specs);
            AbstractReflectorTest.AssertSpec(typeof(ICollection <>), specs);
            AbstractReflectorTest.AssertSpec(typeof(TestObjectWithByteArray), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEnumerable <>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEnumerable), specs);
        }
コード例 #5
0
        public void ReflectObjectType()
        {
            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { typeof(object) }, new Type[] { }, new string[] { });

            rc.SupportedSystemTypes.Clear();

            var container = GetContainer(rc);

            var reflector = container.GetService <IReflector>();

            reflector.Reflect();
            Assert.AreEqual(1, reflector.AllObjectSpecImmutables.Length);

            AbstractReflectorTest.AssertSpec(typeof(object), reflector.AllObjectSpecImmutables.First());
        }
コード例 #6
0
        public void ReflectObjectType()
        {
            IUnityContainer container = GetContainer();

            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { typeof(object) }, new Type[] { }, new string[] { });

            rc.SupportedSystemTypes.Clear();

            container.RegisterInstance <IReflectorConfiguration>(rc);

            var reflector = container.Resolve <IReflector>();

            reflector.Reflect();
            Assert.AreEqual(1, reflector.AllObjectSpecImmutables.Count());

            AbstractReflectorTest.AssertSpec(typeof(object), reflector.AllObjectSpecImmutables.First());
        }
コード例 #7
0
        public void ReflectStringArray()
        {
            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { typeof(TestObjectWithStringArray), typeof(string) }, new Type[] { }, new string[] { });

            rc.SupportedSystemTypes.Clear();

            var container = GetContainer(rc);

            var reflector = container.GetService <IReflector>();

            reflector.Reflect();
            var specs = reflector.AllObjectSpecImmutables;

            Assert.AreEqual(2, specs.Length);

            AbstractReflectorTest.AssertSpec(typeof(TestObjectWithStringArray), specs);
            AbstractReflectorTest.AssertSpec(typeof(string), specs);
        }
コード例 #8
0
        public void ReflectSimpleDomainObject()
        {
            IUnityContainer container = GetContainer();

            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { typeof(SimpleDomainObject) }, new Type[] { }, new[] { "System" });

            rc.SupportedSystemTypes.Clear();
            container.RegisterInstance <IReflectorConfiguration>(rc);

            var reflector = container.Resolve <IReflector>();

            reflector.Reflect();

            var specs = reflector.AllObjectSpecImmutables;

            Assert.AreEqual(19, specs.Length);

            AbstractReflectorTest.AssertSpec(typeof(IComparable <string>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <int>), specs);
            AbstractReflectorTest.AssertSpec(typeof(int), specs);
            AbstractReflectorTest.AssertSpec(typeof(IConvertible), specs);
            AbstractReflectorTest.AssertSpec(typeof(object), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable <char>), specs);
            AbstractReflectorTest.AssertSpec(typeof(char), specs);
            AbstractReflectorTest.AssertSpec(typeof(ValueType), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable), specs);
            AbstractReflectorTest.AssertSpec(typeof(ICloneable), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <string>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEquatable <char>), specs);
            AbstractReflectorTest.AssertSpec(typeof(void), specs);
            AbstractReflectorTest.AssertSpec(typeof(IFormattable), specs);
            AbstractReflectorTest.AssertSpec(typeof(IComparable <int>), specs);
            AbstractReflectorTest.AssertSpec(typeof(SimpleDomainObject), specs);
            AbstractReflectorTest.AssertSpec(typeof(string), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEnumerable <>), specs);
            AbstractReflectorTest.AssertSpec(typeof(IEnumerable), specs);
        }
コード例 #9
0
        public void ReflectSetTypes()
        {
            IUnityContainer container = GetContainer();

            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { typeof(SetWrapper <>), typeof(object) }, new Type[] { }, new string[] { });

            rc.SupportedSystemTypes.Clear();

            container.RegisterInstance <IReflectorConfiguration>(rc);

            var reflector = container.Resolve <IReflector>();

            reflector.Reflect();
            var specs = reflector.AllObjectSpecImmutables;

            Assert.AreEqual(2, specs.Length);

            AbstractReflectorTest.AssertSpec(typeof(object), specs[0]);
            AbstractReflectorTest.AssertSpec(typeof(SetWrapper <>), specs[1]);
        }
コード例 #10
0
        public void ReflectWhereIterator()
        {
            var it = new List <int> {
                1, 2, 3
            }.Where(i => i == 2);

            ReflectorConfiguration.NoValidate = true;

            var rc = new ReflectorConfiguration(new[] { it.GetType().GetGenericTypeDefinition(), typeof(object) }, new Type[] { }, new string[] { });

            rc.SupportedSystemTypes.Clear();

            var container = GetContainer(rc);

            var reflector = container.GetService <IReflector>();

            reflector.Reflect();
            var specs = reflector.AllObjectSpecImmutables;

            Assert.AreEqual(2, specs.Length);

            AbstractReflectorTest.AssertSpec(typeof(object), specs);
            AbstractReflectorTest.AssertSpec(it.GetType().GetGenericTypeDefinition(), specs);
        }