private CodeRootMap CreateBasicMap(out Class cl2)
        {
            CodeRootMap map = new CodeRootMap();

            Class     cl = new Class(controller, "Class1");
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);
            map.AddCodeRoot(root, Version.PrevGen);

            cl      = new Class(controller, "Class1");
            ns      = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            cl2 = new Class(controller, "Class2");
            ns.AddChild(cl2);
            root = new CodeRoot(controller);
            root.AddChild(ns);
            map.AddCodeRoot(root, Version.NewGen);
            return(map);
        }
        private CodeRoot GetPrevGenOrNewGenRoot()
        {
            Class cl = new Class(controller, "Class1");

            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);

            // Create another class to match to the user one.
            Class c3 = new Class(controller, "Class3");

            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c3);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);
            return(root);
        }
        public void Matching_Successful()
        {
            controller.Reorder = true;
            Class cl = new Class(controller, "Class1");

            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            Class            c2    = new Class(controller, "Class2"); // Extra class in user
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c2);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);

            CodeRootMap map = new CodeRootMap();

            map.AddCodeRoot(root, Version.User);

            root = GetPrevGenOrNewGenRoot();
            map.AddCodeRoot(root, Version.PrevGen);

            root = GetPrevGenOrNewGenRoot();
            map.AddCodeRoot(root, Version.NewGen);

            bool matchResult = map.MatchConstructs("ArchAngel.Tests|Class2", "ArchAngel.Tests|Class3", "ArchAngel.Tests|Class3");

            Assert.That(matchResult, Is.True);

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(map.Diff(), Is.EqualTo(TypeOfDiff.UserChangeOnly));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
            Assertions.StringContains(result, "Class2");
            Assertions.StringContains(result, "Class3", 0);
            int count = 0;

            foreach (CodeRootMapNode node in map.AllNodes)
            {
                if (node.IsTheSameReference(c2))
                {
                    count++;
                }
            }
            Assert.That(count, Is.EqualTo(1));
        }
Ejemplo n.º 4
0
        public void PrevGen_Is_Skipped_Where_No_Template_Or_User_Exist()
        {
            Class cl = new Class(controller, "Class1");

            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            Class            c2    = new Class(controller, "Class2"); // Extra class in prevgen
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            ns.AddChild(c2);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);

            CodeRootMap map = new CodeRootMap();

            map.AddCodeRoot(root, Version.PrevGen);

            cl           = new Class(controller, "Class1");
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            attrs = new AttributeSection(controller);
            attr  = new Attribute(controller);
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            ns      = new Namespace(controller);
            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            root = new CodeRoot(controller);
            root.AddChild(ns);

            map.AddCodeRoot(root, Version.User);
            map.AddCodeRoot(root, Version.NewGen);

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
            // make sure that the deleted class Class2 was not included int he merged code root.
            Assertions.StringContains(result, "Class2", 0);
        }
Ejemplo n.º 5
0
        protected CodeRoot CreateClassAndNamespace(IEnumerable <IBaseConstruct> children)
        {
            Class cl = new Class(controller, "Class1");

            foreach (IBaseConstruct child in children)
            {
                cl.AddChild(child);
            }
            cl.Index = 10;
            AttributeSection attrs = new AttributeSection(controller);

            attrs.Index = 5;
            Attribute attr = new Attribute(controller);

            attr.Index = 6;
            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Index = 0;
            ns.Name  = "ArchAngel.Tests";
            ns.AddChild(cl);
            CodeRoot userRoot = new CodeRoot(controller);

            userRoot.AddChild(ns);
            return(userRoot);
        }
Ejemplo n.º 6
0
        public void Class()
        {
            Class cl = new Class(controller, "Class1");

            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);
            CodeRootMap map = new CodeRootMap();

            map.AddCodeRoot(root, Version.User);
            map.AddCodeRoot(root, Version.NewGen);
            map.AddCodeRoot(root, Version.PrevGen);

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
        }
Ejemplo n.º 7
0
        public void They_Should_Not_Show_In_The_Fully_Qualified_Display_Name()
        {
            Namespace ns     = new Namespace(controller);
            Region    region = new Region(controller, "RegionStart");
            Class     clazz  = new Class(controller, "Class1");

            region.AddChild(clazz);
            ns.AddChild(region);

            Assert.That(clazz.FullyQualifiedDisplayName.IndexOf("RegionStart") < 0,
                        "The fully qualified display name of the Class should not contain the region name");
        }
Ejemplo n.º 8
0
        public void Struct()
        {
            Struct cl = new Struct(controller, "Struct1");

            Assert.That(cl.FullyQualifiedDisplayName, Is.EqualTo("Struct1"));

            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(cl);

            Assert.That(cl.FullyQualifiedDisplayName, Is.EqualTo("ns1.Struct1"));
        }
Ejemplo n.º 9
0
        public void Namespace()
        {
            Namespace item = new Namespace(controller, "Namespace1");

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Namespace1"));

            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(item);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("ns1.Namespace1"));
        }
Ejemplo n.º 10
0
        public void Class()
        {
            Class cl = new Class(controller, "Class1");

            Assert.That(cl.FullyQualifiedDisplayName, Is.EqualTo("Class1"));

            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(cl);

            Assert.That(cl.FullyQualifiedDisplayName, Is.EqualTo("ns1.Class1"));
        }
        protected CodeRoot CreateBasicRoot()
        {
            Class     cl = new Class(controller, "Class1");
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);

            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);
            return(root);
        }
        public void Interface()
        {
            Interface item = new Interface(controller, "Interface1");

            Assert.That(item.FullyQualifiedIdentifer, Is.EqualTo("Interface1"));

            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(item);

            Assert.That(item.FullyQualifiedIdentifer, Is.EqualTo("ns1|Interface1"));
        }
Ejemplo n.º 13
0
        public void InterfaceProperty()
        {
            Interface         it   = new Interface(controller, "Interface1");
            InterfaceProperty item = new InterfaceProperty(controller, "Property1", new DataType(controller, "int"));

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Property1"));

            it.AddChild(item);
            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(it);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("ns1.Interface1.Property1"));
        }
        public void Namespace()
        {
            Namespace inter = new Namespace(controller);

            inter.Name = "File";
            inter.AddChild(new Class(controller, "Class1"));

            Namespace clone = (Namespace)inter.Clone();

            clone.Controller = new CSharpController();

            Assert.That(inter.IsTheSame(clone, ComparisonDepth.Outer), Is.True);
            Assert.That(clone.WalkChildren(), Has.Count(0));
            Assert.That(inter.IsTheSame(clone, ComparisonDepth.Complete), Is.False);
        }
Ejemplo n.º 15
0
        public void InterfaceEvent()
        {
            Interface      it   = new Interface(controller, "Interface1");
            InterfaceEvent item = new InterfaceEvent(controller, "Event1", new DataType(controller, "Delegate1"), false);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Event1"));

            it.AddChild(item);
            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(it);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("ns1.Interface1.Event1"));
        }
        public void SetUp()
        {
            var controller = new CSharpController();

            codeRoot = new CodeRoot(controller);
            var ns = new Namespace(controller, "Namespace1")
            {
                Index = 0
            };

            codeRoot.AddChild(ns);
            ns.AddChild(new Class(controller, "Class1")
            {
                Index = 1
            });
        }
Ejemplo n.º 17
0
        public void InterfaceIndexer()
        {
            Interface        it   = new Interface(controller, "Interface1");
            InterfaceIndexer item = new InterfaceIndexer(controller, new DataType(controller, "int"), false);

            item.Parameters.Add(new Parameter(controller, "float", "f"));
            item.Parameters.Add(new Parameter(controller, "InputObject", "j"));
            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Indexer [float, InputObject]"));

            it.AddChild(item);
            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(it);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("ns1.Interface1.Indexer [float, InputObject]"));
        }
Ejemplo n.º 18
0
        public void InterfaceMethod()
        {
            Interface       it   = new Interface(controller, "Interface1");
            InterfaceMethod item = new InterfaceMethod(controller, "Function1", new DataType(controller, "int"));

            item.Parameters.Add(new Parameter(controller, "float", "f"));
            item.Parameters.Add(new Parameter(controller, "InputObject", "j"));
            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Function1 (float, InputObject)"));

            it.AddChild(item);
            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(it);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("ns1.Interface1.Function1 (float, InputObject)"));
        }
Ejemplo n.º 19
0
        public void User_Is_Missing_Others_Are_Exact_Copy()
        {
            Function func = new Function(controller);

            func.Name = "Method1";
            func.Modifiers.Add("public");
            func.ReturnType = new DataType(controller, "void");
            func.BodyText   = "{ }";

            Class cl = new Class(controller, "Class1");

            cl.AddChild(func);
            cl.IsPartial = true;
            cl.GenericTypes.Add("T");
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);
            CodeRootMap map = new CodeRootMap();

            map.AddCodeRoot(root, Version.PrevGen);
            map.AddCodeRoot(root, Version.NewGen);

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "public void Method1()");
            Assertions.StringContains(result, "{ }");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
        }
Ejemplo n.º 20
0
        public void They_Should_Not_Show_In_The_Object_Heirarchy()
        {
            Namespace ns = new Namespace(controller)
            {
                Index = 1
            };
            Region region = new Region(controller, "RegionStart")
            {
                Index = 2
            };
            Class clazz = new Class(controller, "Class1")
            {
                Index = 3
            };

            region.AddChild(clazz);
            ns.AddChild(region);

            Assert.That(clazz.Parent, Is.SameAs(ns), "The parent of the Class should be the Namespace, not the Region");
        }
Ejemplo n.º 21
0
        protected CodeRoot ConstructRootWithClass(IBaseConstruct childOfClass)
        {
            Class cl = new Class(controller, "Class1");

            cl.AddChild(childOfClass);
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            cl.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);
            return(root);
        }
Ejemplo n.º 22
0
        public void Namespace()
        {
            Namespace inter = new Namespace(controller);

            inter.Name = "ArchAngel.Tests";
            inter.AddChild(new UsingStatement(controller, "", "System"));
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(inter);

            CodeRootMap map = new CodeRootMap();

            map.AddCodeRoot(root, Version.User);
            map.AddCodeRoot(root, Version.NewGen);
            map.AddCodeRoot(root, Version.PrevGen);

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(result, Is.EqualTo(root.ToString()));
            Assertions.StringContains(result, "using System");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
        }
Ejemplo n.º 23
0
        protected CodeRoot CreateNamespaceAndInterface(IBaseConstruct inter)
        {
            Interface interface1 = new Interface(controller, "Interface1");

            interface1.Modifiers.Add("public");
            interface1.AddChild(inter);
            AttributeSection attrs = new AttributeSection(controller);
            Attribute        attr  = new Attribute(controller);

            attr.PositionalArguments.Add("true");
            attr.Name = "Serializable";
            attrs.AddAttribute(attr);
            interface1.AddAttributeSection(attrs);
            Namespace ns = new Namespace(controller);

            ns.Name = "ArchAngel.Tests";
            ns.AddChild(interface1);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns);
            return(root);
        }
Ejemplo n.º 24
0
        public void InterfaceAccessor()
        {
            InterfaceProperty itp   = new InterfaceProperty(controller, "Property1", new DataType(controller, "int"));
            InterfaceAccessor item1 = new InterfaceAccessor(controller, ArchAngel.Providers.CodeProvider.DotNet.InterfaceAccessor.AccessorTypes.Get, "");
            InterfaceAccessor item2 = new InterfaceAccessor(controller, ArchAngel.Providers.CodeProvider.DotNet.InterfaceAccessor.AccessorTypes.Set, "");

            itp.AddChild(item1);
            itp.AddChild(item2);

            Assert.That(item1.FullyQualifiedDisplayName, Is.EqualTo("Property1.Get Accessor"));
            Assert.That(item2.FullyQualifiedDisplayName, Is.EqualTo("Property1.Set Accessor"));

            Interface it = new Interface(controller, "Interface1");

            it.AddChild(itp);
            Namespace ns = new Namespace(controller);

            ns.Name = "ns1";
            ns.AddChild(it);

            Assert.That(item1.FullyQualifiedDisplayName, Is.EqualTo("ns1.Interface1.Property1.Get Accessor"));
            Assert.That(item2.FullyQualifiedDisplayName, Is.EqualTo("ns1.Interface1.Property1.Set Accessor"));
        }
        public void Matching_Successful()
        {
            CodeRootMap map = new CodeRootMap();

            Class     cl  = new Class(controller, "Class1");
            Namespace ns1 = new Namespace(controller);

            ns1.Name = "ArchAngel.Tests";
            ns1.AddChild(cl);
            CodeRoot root = new CodeRoot(controller);

            root.AddChild(ns1);
            map.AddCodeRoot(root, Version.User);

            cl = new Class(controller, "Class1");
            Namespace ns2 = new Namespace(controller);

            ns2.Name = "Slyce.Tests";
            ns2.AddChild(cl);
            root = new CodeRoot(controller);
            root.AddChild(ns2);
            map.AddCodeRoot(root, Version.PrevGen);

            cl = new Class(controller, "Class1");
            Namespace ns3 = new Namespace(controller);

            ns3.Name = "Slyce.Tests";
            ns3.AddChild(cl);
            root = new CodeRoot(controller);
            root.AddChild(ns3);
            map.AddCodeRoot(root, Version.NewGen);

            map.MatchConstructs(map, ns1, ns3, ns2);

            foreach (CodeRootMapNode child in map.AllNodes)
            {
                Assert.That(child.PrevGenObj, Is.Not.Null,
                            string.Format("PrevGen in {0} is null", child.GetFirstValidBaseConstruct().ShortName));
                Assert.That(child.NewGenObj, Is.Not.Null,
                            string.Format("NewGen in {0} is null", child.GetFirstValidBaseConstruct().ShortName));
                Assert.That(child.UserObj, Is.Not.Null,
                            string.Format("User in {0} is null", child.GetFirstValidBaseConstruct().ShortName));
            }

            string result = map.GetMergedCodeRoot().ToString();

            Assert.That(map.Diff(), Is.EqualTo(TypeOfDiff.UserChangeOnly));
            Assertions.StringContains(result, "class Class1", 1);
            Assertions.StringContains(result, "namespace ArchAngel.Tests", 1);
            Assertions.StringContains(result, "namespace Slyce.Tests", 0);

            int count = 0;

            foreach (CodeRootMapNode node in map.AllNodes)
            {
                if (node.IsTheSameReference(ns1))
                {
                    count++;
                }
            }
            Assert.That(count, Is.EqualTo(1));
        }