Beispiel #1
0
        public void LoadsFromAssemblies()
        {
            var found = TypeLoader.Create(new[] { @"..\..\Gamlor.Db4oPad.ExternalAssemblyForTests.dll" })
                            (TypeNameParser.ParseString("Gamlor.Db4oPad.ExternalAssemblyForTests.AType, Gamlor.Db4oPad.ExternalAssemblyForTests"));

            Assert.IsNotNull(found.Value);
        }
Beispiel #2
0
        public void LoadGenericType()
        {
            var found = TypeLoader.Create(new[] { @"..\..\Gamlor.Db4oPad.ExternalAssemblyForTests.dll" })
                            (TypeNameParser.ParseString("Gamlor.Db4oPad.ExternalAssemblyForTests.AGeneric`1[[System.Int32, mscorlib]], Gamlor.Db4oPad.ExternalAssemblyForTests"));

            Assert.IsTrue(found.HasValue);
            Assert.IsNotNull(found.Value.GetConstructors().Single().Invoke(new object[0]));
        }
Beispiel #3
0
        public void GetsGenericTypeFromCurrentAssembly()
        {
            var dynamicType     = new [] { TestMetaData.CreateGenericType() };
            var dynamicAssembly = CodeGenerator.Create(dynamicType, TestUtils.NewName());
            var typeToFind      = dynamicAssembly.Types[dynamicType.Single(t => t.IsBusinessEntity)];
            var found           = TypeLoader.Create(new string[0])(TypeNameParser.ParseString(ReflectPlatform.FullyQualifiedName(typeToFind)));

            Assert.AreEqual(typeToFind, found.Value);
        }
Beispiel #4
0
        public void NestedClasses()
        {
            var input  = "Db4oPad.TestDBs.NestedClasses+ChildClass, Db4oPad.TestDBs";
            var result = TypeNameParser.ParseString(input);

            Assert.AreEqual("Db4oPad.TestDBs.NestedClasses+ChildClass", result.NameAndNamespace);
            Assert.AreEqual("Db4oPad.TestDBs", result.AssemblyName);
            Assert.AreEqual(input, result.FullName);
            Assert.AreEqual("ChildClass", result.Name);
        }
Beispiel #5
0
        public void MultiNestedGeneric()
        {
            var input = "Gamlor.Db4oPad.Tests.TypeGeneration.Generic`2[[System.String, mscorlib], [System.Collections.Generic.List`1[[System.String, mscorlib]], mscorlib]], Gamlor.Db4oPad.Tests";


            var result = TypeNameParser.ParseString(input);

            Assert.AreEqual("Gamlor.Db4oPad.Tests.TypeGeneration.Generic`2", result.NameAndNamespace);
            Assert.AreEqual("Gamlor.Db4oPad.Tests", result.AssemblyName);
        }
Beispiel #6
0
        public void ParseGenericNested()
        {
            var input = string.Format("Namespace.Map`2[{0}, [Namespace.List`1[{0}], {1}]], {1}", GenericArg, AsseblyName);

            var result = TypeNameParser.ParseString(input);

            Assert.AreEqual("Namespace.Map`2", result.NameAndNamespace);
            Assert.AreEqual(AsseblyName, result.AssemblyName);
            ValidateGenericArgs(result.GenericArguments.Take(1));
            ValidateGenericArgs(result.GenericArguments.Last().Value.GenericArguments);
        }
Beispiel #7
0
        public void MultiGenericNested()
        {
            var input = string.Format("Namespace.MainClass`1+NestedClass`2[{0}, {0}, {0}], {1}", GenericArg, AsseblyName);

            var result = TypeNameParser.ParseString(input);

            Assert.AreEqual("Namespace.MainClass`1+NestedClass`2", result.NameAndNamespace);
            Assert.AreEqual(AsseblyName, result.AssemblyName);
            ValidateGenericArgs(result.GenericArguments.Take(1));
            ValidateGenericArgs(result.GenericArguments.Skip(1).Take(1));
            ValidateGenericArgs(result.GenericArguments.Last().Value.GenericArguments);
        }
Beispiel #8
0
        public void StringArray()
        {
            var input = "System.String[], mscorlib";


            var result = TypeNameParser.ParseString(input);

            Assert.AreEqual("System.String[]", result.NameAndNamespace);
            Assert.AreEqual("mscorlib", result.AssemblyName);
            Assert.AreEqual("System.String[], mscorlib", result.FullName);
            Assert.AreEqual(1, result.OrderOfArray);
            Assert.AreEqual("System.String, mscorlib", result.ArrayOf.Value.FullName);
        }