Пример #1
0
        public void SystemTypeEquals()
        {
            var t1 = KnownType.Create(typeof(string));
            var t2 = KnownType.Create(typeof(string));

            Assert.AreEqual(t1, t2);
        }
Пример #2
0
        public void CanBuildDictionary()
        {
            var theType = KnownType.Create(typeof(Dictionary <,>),
                                           new[] { KnownType.String, KnownType.String });

            Assert.NotNull(theType);
        }
Пример #3
0
        private IEnumerable <ITypeDescription> CreateSingleIntFieldClass()
        {
            var stringType = KnownType.Create(typeof(int));
            var type       = SimpleClassDescription.Create(TestMetaData.SingleFieldType(),
                                                           f => TestMetaData.CreateField(stringType));

            return(new[] { type, stringType });
        }
Пример #4
0
        public static IEnumerable <ITypeDescription> CreateClassListGenericOf(ITypeDescription typeOfLists)
        {
            var listType = KnownType.Create(typeof(List <>), new[] { typeOfLists });
            var type     = SimpleClassDescription.Create(SingleFieldType(),
                                                         f => CreateField(listType));

            return(new[] { type, listType, typeOfLists });
        }
Пример #5
0
        internal static IEnumerable <ITypeDescription> TypeWithGenericList()
        {
            var stringList = KnownType.Create(typeof(List <string>));
            var type       = SimpleClassDescription.Create(TestMetaData.SingleFieldType(),
                                                           f => TestMetaData.CreateField(stringList));

            return(new[] { type, stringList });
        }
Пример #6
0
        public void CanResolveFullyKnownType()
        {
            var theType = KnownType.Create(
                typeof(Dictionary <ClassWithoutFields, ClassWithoutFields>),
                new[] { KnownType.Create(typeof(ClassWithoutFields)), KnownType.Create(typeof(ClassWithoutFields)) });

            Assert.NotNull(theType);
            Assert.NotNull(theType.TryResolveType(t => typeof(ClassWithoutFields)));
        }
Пример #7
0
        public void ResolvesGenericParameters()
        {
            var otherType    = TestMetaData.CreateEmptyClassMetaInfo();
            var theType      = KnownType.Create(typeof(System.Collections.Generic.List <>), otherType);
            var resovledType = theType.TryResolveType(t => typeof(string));

            Assert.AreEqual(typeof(System.Collections.Generic.List <string>), resovledType.Value);
            Assert.IsTrue(theType.TypeName.FullName.StartsWith("System.Collections.Generic.List"));
        }
Пример #8
0
        private IEnumerable <ITypeDescription> SubClassType()
        {
            var baseClasses = TestMetaData.CreateSingleFieldClass();
            var intType     = KnownType.Create(typeof(int));
            var baseClass   = baseClasses.Single(b => !b.TryResolveType(TestUtils.FindNothingTypeResolver).HasValue);
            var subType     = SimpleClassDescription.Create(
                TypeName.Create("ANamespace.SubClass", TestMetaData.AssemblyName), Maybe.From(baseClass),
                f => TestMetaData.CreateField("subField", intType));

            return(baseClasses.Concat(new[] { intType, subType }));
        }
Пример #9
0
        internal static IEnumerable <ITypeDescription> GenericType()
        {
            var stringList       = KnownType.Create(typeof(List <string>));
            var stringType       = typeof(string);
            var genericArguments = GenericArg(stringType);
            var type             = SimpleClassDescription.Create(TypeName.Create(TestMetaData.SingleFieldTypeName + "`1",
                                                                                 TestMetaData.AssemblyName, genericArguments),
                                                                 f => TestMetaData.CreateField(stringList));

            return(new[] { type, stringList });
        }
Пример #10
0
        public void CanAccessExistingArrayType()
        {
            var knownType      = KnownType.Create(typeof(ClassWithFields));
            var knownTypeArray = ArrayDescription.Create(knownType, 1);
            var metaInfo       = new[] { knownType, knownTypeArray };

            var result = CodeGenerator.Create(metaInfo,
                                              Assembly.GetAssembly(typeof(TestTypeGeneration)));
            var arrayType = result.Types[knownTypeArray];

            Assert.NotNull(arrayType);
        }
Пример #11
0
        private static IEnumerable <ITypeDescription> TwoGenericInstances()
        {
            var stringList        = KnownType.Create(typeof(List <string>));
            var stringType        = typeof(string);
            var stringGenericArgs = GenericArg(stringType);
            var stringInstance    = SimpleClassDescription.Create(TypeName.Create(TestMetaData.SingleFieldTypeName, TestMetaData.AssemblyName, stringGenericArgs),
                                                                  f => TestMetaData.CreateField(stringList));

            var intList        = KnownType.Create(typeof(List <int>));
            var intType        = typeof(int);
            var intGenericArgs = GenericArg(intType);
            var intInstance    = SimpleClassDescription.Create(TypeName.Create(TestMetaData.SingleFieldTypeName, TestMetaData.AssemblyName, intGenericArgs),
                                                               f => TestMetaData.CreateField(intList));

            return(new[] { stringInstance, intInstance, stringList, intList });
        }
Пример #12
0
        public void NestedClassesAreUnderlined()
        {
            var listType = KnownType.Create(typeof(ClassWithProperty.NestedClass));

            Assert.IsTrue(listType.TypeName.NameWithGenerics.EndsWith("ClassWithProperty_NestedClass"));
        }
Пример #13
0
        public void NameOfGenericInstance()
        {
            var listType = KnownType.Create(typeof(List <>), new[] { KnownType.String });

            Assert.IsTrue(listType.TypeName.FullName.StartsWith("System.Collections.Generic.List`1["));
        }
Пример #14
0
        public void KnownTypeReturnsPropertyFields()
        {
            var theType = KnownType.Create(typeof(ClassWithProperty));

            Assert.AreEqual(1, theType.Fields.Count());
        }
Пример #15
0
        public void KnownTypeIsBusinessType()
        {
            var theType = KnownType.Create(typeof(ClassWithFields));

            Assert.IsTrue(theType.IsBusinessEntity);
        }
Пример #16
0
        public void Db4oTypeIsNotBusinessType()
        {
            var theType = KnownType.Create(typeof(ActivatableList <string>));

            Assert.IsFalse(theType.IsBusinessEntity);
        }