public void NameCorrectlyAcquired()
        {
            // Assembling some code
            IAssemblyLoader assemblyLoader = new Utils.AsmlDasmlAssemblyLoader(@"
                class MyClass {
                }
            ");

            // Loading the assembly
            IAssemblyProxy assembly = assemblyLoader.Load();

            // Locating the class
            ITypeInfoProxy classDefinition = assembly.LocateType("MyClass");

            Assert.IsNotNull(classDefinition);

            // Generating the AST
            var factory    = new ClassDeclarationSyntaxFactory(classDefinition);
            var syntaxNode = factory.Create();

            Assert.IsNotNull(syntaxNode, "A node was expected to be built");
            Assert.IsInstanceOfType(syntaxNode, typeof(ClassDeclarationSyntax), "Expected a class declaration node to be built");

            var classDeclarationSyntaxNode = syntaxNode as ClassDeclarationSyntax;

            var name = classDeclarationSyntaxNode.Identifier.Text;

            Assert.AreEqual("MyClass", name, "Class name not correctly acquired");
        }
        private static void TestVisibility(string source, string className, SyntaxKind?expectedVisibility)
        {
            // Assembling some code
            IAssemblyLoader assemblyLoader = new Utils.AsmlDasmlAssemblyLoader(source);

            // Loading the assembly
            IAssemblyProxy assembly = assemblyLoader.Load();

            // Locating the class
            ITypeInfoProxy classDefinition = assembly.LocateType(className);

            Assert.IsNotNull(classDefinition);

            // Generating the AST
            var factory    = new ClassDeclarationSyntaxFactory(classDefinition);
            var syntaxNode = factory.Create();

            Assert.IsNotNull(syntaxNode, "A node was expected to be built");
            Assert.IsInstanceOfType(syntaxNode, typeof(ClassDeclarationSyntax), "Expected a class declaration node to be built");

            var classDeclarationSyntaxNode = syntaxNode as ClassDeclarationSyntax;

            var modifiers = classDeclarationSyntaxNode.Modifiers;

            if (expectedVisibility.HasValue)
            {
                Assert.IsTrue(Utils.CheckModifier(modifiers, expectedVisibility.Value), "Class does not have correct visibility");
                return;
            }

            Assert.AreEqual(0, modifiers.Count(), "Expected no modifier");
        }
        public void ImplicitObjectClassInheritanceIsNotGenerated()
        {
            // Assembling some code
            IAssemblyLoader assemblyLoader = new Utils.AsmlDasmlAssemblyLoader(@"
                class MyClass {
                }
            ");

            // Loading the assembly
            IAssemblyProxy assembly = assemblyLoader.Load();

            // Locating the class
            ITypeInfoProxy classDefinition = assembly.LocateType("MyClass");

            Assert.IsNotNull(classDefinition);

            // Generating the AST
            var factory    = new ClassDeclarationSyntaxFactory(classDefinition);
            var syntaxNode = factory.Create();

            Assert.IsNotNull(syntaxNode, "A node was expected to be built");
            Assert.IsInstanceOfType(syntaxNode, typeof(ClassDeclarationSyntax), "Expected a class declaration node to be built");

            var classDeclarationSyntaxNode = syntaxNode as ClassDeclarationSyntax;

            var baseList = classDeclarationSyntaxNode.BaseList;

            Assert.IsNull(baseList, "No base class should have been generated");
        }
        public void InterfaceNamesCorrectlyAcquired()
        {
            // Assembling some code
            IAssemblyLoader assemblyLoader = new Utils.AsmlDasmlAssemblyLoader(@"
                interface MyInterface1 {
                }
                interface MyInterface2 {
                }
                interface MyInterface3 {
                }
                class MyClass : MyInterface1, MyInterface2, MyInterface3 {
                }
            ");

            // Loading the assembly
            IAssemblyProxy assembly = assemblyLoader.Load();

            // Locating the class
            ITypeInfoProxy classDefinition = assembly.LocateType("MyClass");

            Assert.IsNotNull(classDefinition);

            // Generating the AST
            var factory    = new ClassDeclarationSyntaxFactory(classDefinition);
            var syntaxNode = factory.Create();

            Assert.IsNotNull(syntaxNode, "A node was expected to be built");
            Assert.IsInstanceOfType(syntaxNode, typeof(ClassDeclarationSyntax), "Expected a class declaration node to be built");

            var classDeclarationSyntaxNode = syntaxNode as ClassDeclarationSyntax;
            var baseList = classDeclarationSyntaxNode.BaseList.Types;

            Assert.AreEqual(3, baseList.Count, "Expected 3 interfaces");

            Action <int, string> NameChecker = (index, expectedName) =>
            {
                var baseType           = classDeclarationSyntaxNode.BaseList.Types.ElementAt(index);
                var baseTypeIdentifier = baseType.Type as IdentifierNameSyntax;

                Assert.IsNotNull(baseTypeIdentifier, "Identifier expected");

                var baseTypeName = baseTypeIdentifier.ToString();
                Assert.AreEqual(expectedName, baseTypeName, "Base type full name not correct");
            };

            NameChecker(0, "MyInterface1");
            NameChecker(1, "MyInterface2");
            NameChecker(2, "MyInterface3");
        }
        private static void TestInterfaceFullNames(string source, string className, string[] expectedInterfaceFullNames)
        {
            // Assembling some code
            IAssemblyLoader assemblyLoader = new ScriptSharpReflectionUtils.AsmlDasmlAssemblyLoader(source,
                                                                                                    ScriptNamespaceAttributeHelper.AttributeSourceCode);

            // Loading the assembly
            IAssemblyProxy assembly = assemblyLoader.Load();
            ITypeLookup    lookup   = new LinearSearchTypeLookup(assembly);

            // Locating the class
            ITypeInfoProxy classDefinition = assembly.LocateType(className);

            Assert.IsNotNull(classDefinition);

            // Generating the AST
            var factory    = new ClassDeclarationSyntaxFactory(classDefinition, lookup);
            var syntaxNode = factory.Create();

            Assert.IsNotNull(syntaxNode, "A node was expected to be built");
            Assert.IsInstanceOfType(syntaxNode, typeof(ClassDeclarationSyntax), "Expected a class declaration node to be built");

            var classDeclarationSyntaxNode = syntaxNode as ClassDeclarationSyntax;
            var baseList = classDeclarationSyntaxNode.BaseList.Types;

            Assert.AreEqual(expectedInterfaceFullNames.Length, baseList.Count, $"Expected {expectedInterfaceFullNames.Length} interfaces");

            Action <int, string> NameChecker = (index, expectedName) =>
            {
                var baseType           = classDeclarationSyntaxNode.BaseList.Types.ElementAt(index);
                var baseTypeIdentifier = baseType.Type as QualifiedNameSyntax;

                Assert.IsNotNull(baseTypeIdentifier, "Qualified name expected");

                var baseTypeName = baseTypeIdentifier.ToString();
                Assert.AreEqual(expectedName, baseTypeName, "Base type full name not correct");
            };

            for (int i = 0; i < expectedInterfaceFullNames.Length; i++)
            {
                NameChecker(i, expectedInterfaceFullNames[i]);
            }
        }
        public void BaseTypeNameCorrectlyAcquired()
        {
            // Assembling some code
            IAssemblyLoader assemblyLoader = new Utils.AsmlDasmlAssemblyLoader(@"
                class MyBaseClass {
                }
                class MyClass : MyBaseClass {
                }
            ");

            // Loading the assembly
            IAssemblyProxy assembly = assemblyLoader.Load();

            // Locating the class
            ITypeInfoProxy classDefinition = assembly.LocateType("MyClass");

            Assert.IsNotNull(classDefinition);

            // Generating the AST
            var factory    = new ClassDeclarationSyntaxFactory(classDefinition);
            var syntaxNode = factory.Create();

            Assert.IsNotNull(syntaxNode, "A node was expected to be built");
            Assert.IsInstanceOfType(syntaxNode, typeof(ClassDeclarationSyntax), "Expected a class declaration node to be built");

            var classDeclarationSyntaxNode = syntaxNode as ClassDeclarationSyntax;
            var baseList = classDeclarationSyntaxNode.BaseList.Types;

            Assert.AreEqual(1, baseList.Count, "Expected one base class only");

            var baseType           = classDeclarationSyntaxNode.BaseList.Types.First();
            var baseTypeIdentifier = baseType.Type as IdentifierNameSyntax;

            Assert.IsNotNull(baseTypeIdentifier, "Identifier expected");

            var baseTypeName = baseTypeIdentifier.ToString();

            Assert.AreEqual("MyBaseClass", baseTypeName, "Base type full name not correct");
        }
        private static void TestBaseClassFullName(string source, string className, string expectedBaseTypeName)
        {
            // Assembling some code
            IAssemblyLoader assemblyLoader = new ScriptSharpReflectionUtils.AsmlDasmlAssemblyLoader(source,
                                                                                                    ScriptNamespaceAttributeHelper.AttributeSourceCode);

            // Loading the assembly
            IAssemblyProxy assembly = assemblyLoader.Load();
            ITypeLookup    lookup   = new LinearSearchTypeLookup(assembly);

            // Locating the class
            ITypeInfoProxy classDefinition = assembly.LocateType(className);

            Assert.IsNotNull(classDefinition);

            // Generating the AST
            var factory    = new ClassDeclarationSyntaxFactory(classDefinition, lookup);
            var syntaxNode = factory.Create();

            Assert.IsNotNull(syntaxNode, "A node was expected to be built");
            Assert.IsInstanceOfType(syntaxNode, typeof(ClassDeclarationSyntax), "Expected a class declaration node to be built");

            var classDeclarationSyntaxNode = syntaxNode as ClassDeclarationSyntax;
            var baseList = classDeclarationSyntaxNode.BaseList.Types;

            Assert.AreEqual(1, baseList.Count, "Expected one base class only");

            var baseType           = classDeclarationSyntaxNode.BaseList.Types.First();
            var baseTypeIdentifier = baseType.Type as QualifiedNameSyntax;

            Assert.IsNotNull(baseTypeIdentifier, "QUalified name expected");

            var baseTypeName = baseTypeIdentifier.ToString();

            Assert.AreEqual(expectedBaseTypeName, baseTypeName, "Base type full name not correct");
        }