private Type SingleTypeQueryContext() { var metaInfo = TestMetaData.CreateEmptyClassMetaInfo(); var infos = NewTestInstance(metaInfo); return(infos.DataContext); }
public void HasMetaDataProperty() { object dataContext = GetDataContext(TestMetaData.CreateEmptyClassMetaInfo()); var metaData = GetMetaDataProperty(dataContext); Assert.IsNotNull(metaData); }
public void CanInstantiateGenericWithClass() { var metaInfo = TestMetaData.CreateEmptyClassMetaInfo(); var type = GenerateSingle(metaInfo); var genericList = typeof(List <>).MakeGenericType(type); var list = genericList.GetConstructor(new Type[0]).Invoke(new object[0]); }
public void GenerateEmptyClass() { var metaInfo = TestMetaData.CreateEmptyClassMetaInfo(); var type = GenerateSingle(metaInfo); Assert.IsTrue(type.Name.StartsWith(metaInfo.Single().Name)); }
public void HasNames() { var originalMetaData = TestMetaData.CreateEmptyClassMetaInfo(); dynamic metaData = MetaClassInfo(originalMetaData); Assert.AreEqual("EmptyClass", metaData.EmptyClass.ClassName); Assert.AreEqual(originalMetaData.Single().TypeName.FullName, metaData.EmptyClass.ClassFullName); }
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")); }
public void ArrayOfGeneratedType() { var simpleType = TestMetaData.CreateEmptyClassMetaInfo(); var code = CodeGenerator.Create(simpleType, TestUtils.NewName()); var generatedType = code.Types[simpleType.Single()]; var type = generatedType.MakeArrayType(); Assert.IsTrue(type.AssemblyQualifiedName.Contains("[]")); }
public void CanInstantiateClass() { var metaInfo = TestMetaData.CreateEmptyClassMetaInfo(); var type = GenerateSingle(metaInfo); var instance = CreateInstance(type); Assert.NotNull(instance); }
public void HasAssembly() { var metaInfo = TestMetaData.CreateEmptyClassMetaInfo(); var name = TestUtils.NewName(); var infos = CodeGenerator.Create(metaInfo, name); Assert.IsTrue(File.Exists(name.CodeBase)); }
public void CanCreateTypeMultipleTimes() { var metaInfo = TestMetaData.CreateEmptyClassMetaInfo(); var type1 = SingleNotObject(metaInfo); var type2 = SingleNotObject(metaInfo); Assert.NotNull(type1); Assert.NotNull(type2); }
public void CreateMixedGenericInstance() { var metaInfo = TestMetaData.CreateClassListGenericOf(TestMetaData.CreateEmptyClassMetaInfo().First()); var types = NewTestInstance(metaInfo); var genericTypes = types.Types[metaInfo.First()]; var fields = genericTypes.GetFields(); Assert.AreEqual(typeof(List <>), fields.Single().FieldType.GetGenericTypeDefinition()); }
public void ArraysAreLowerBoundZero() { var arrayType = TestMetaData.CreateEmptyClassMetaInfo().Single(); var metaInfo = SimpleClassDescription.Create(TestMetaData.SingleFieldType(), f => TestMetaData.CreateArrayField(arrayType)); var type = ExtractSingleFieldType(new[] { metaInfo }); var fieldType = type.GetField("data").FieldType; Assert.IsTrue(fieldType.AssemblyQualifiedName.Contains("[]")); }
public void DoesAddPartialGenerics() { var meta = TestMetaData.CreateClassListGenericOf(TestMetaData.CreateEmptyClassMetaInfo().Single()); var db = Configure(DatabaseMetaInfo.Create(meta, TestUtils.NewName())); var typeWithGenericField = meta.First(); var fieldType = typeWithGenericField.Fields.Single(); var typeInfo = db.Ext().Reflector().ForName(fieldType.Type.TypeName.FullName); Assert.NotNull(typeInfo); Assert.IsTrue(typeInfo.GetName().StartsWith("System.Collections.Generic.List`1[[ANamespace")); }
public void HasConfiguredReflector() { var meta = TestMetaData.CreateEmptyClassMetaInfo(); var dynamicClass = meta.Single(); var metaInfo = DatabaseMetaInfo.Create( TestMetaData.CreateEmptyClassMetaInfo(), AssemblyName()); var db = Configure(metaInfo); var typeInfo = db.Ext().Reflector().ForName(dynamicClass.TypeName.FullName); Assert.AreEqual(dynamicClass.TypeName.FullName, typeInfo.GetName()); }
public void IsInRightAssembly() { var metaInfo = TestMetaData.CreateEmptyClassMetaInfo(); var assemblyName = new AssemblyName("Gamlor.Dynamic.Name.Of.This.Assembly") { CodeBase = Path.GetTempFileName(), Version = new Version(1, 0, 0, 1), CultureInfo = CultureInfo.InvariantCulture }; var type = CodeGenerator.Create(metaInfo, assemblyName).Single(SingleNotObject); var generatedAssembly = type.Value.Assembly.GetName(); Assert.AreEqual(assemblyName.Name, generatedAssembly.Name); Assert.AreEqual(assemblyName.Version, generatedAssembly.Version); Assert.AreEqual(assemblyName.CultureInfo, generatedAssembly.CultureInfo); }
private object MetaClassInfo() { return(MetaClassInfo(TestMetaData.CreateEmptyClassMetaInfo())); }