public void SystemTypeEquals() { var t1 = KnownType.Create(typeof(string)); var t2 = KnownType.Create(typeof(string)); Assert.AreEqual(t1, t2); }
public void CanBuildDictionary() { var theType = KnownType.Create(typeof(Dictionary <,>), new[] { KnownType.String, KnownType.String }); Assert.NotNull(theType); }
private IEnumerable <ITypeDescription> CreateSingleIntFieldClass() { var stringType = KnownType.Create(typeof(int)); var type = SimpleClassDescription.Create(TestMetaData.SingleFieldType(), f => TestMetaData.CreateField(stringType)); return(new[] { type, stringType }); }
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 }); }
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 }); }
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))); }
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")); }
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 })); }
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 }); }
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); }
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 }); }
public void NestedClassesAreUnderlined() { var listType = KnownType.Create(typeof(ClassWithProperty.NestedClass)); Assert.IsTrue(listType.TypeName.NameWithGenerics.EndsWith("ClassWithProperty_NestedClass")); }
public void NameOfGenericInstance() { var listType = KnownType.Create(typeof(List <>), new[] { KnownType.String }); Assert.IsTrue(listType.TypeName.FullName.StartsWith("System.Collections.Generic.List`1[")); }
public void KnownTypeReturnsPropertyFields() { var theType = KnownType.Create(typeof(ClassWithProperty)); Assert.AreEqual(1, theType.Fields.Count()); }
public void KnownTypeIsBusinessType() { var theType = KnownType.Create(typeof(ClassWithFields)); Assert.IsTrue(theType.IsBusinessEntity); }
public void Db4oTypeIsNotBusinessType() { var theType = KnownType.Create(typeof(ActivatableList <string>)); Assert.IsFalse(theType.IsBusinessEntity); }