public void Matching_Successful()
        {
            CodeRootMap map = new CodeRootMap();

            CodeRoot userroot = CreateBasicRoot();

            map.AddCodeRoot(userroot, Version.User);

            CodeRoot prevroot = CreateBasicRoot();

            map.AddCodeRoot(prevroot, Version.PrevGen);

            CodeRoot templateroot = CreateBasicRoot();

            map.AddCodeRoot(templateroot, Version.NewGen);

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

            Assertions.StringContains(result, "class Class1", 1);
            Assertions.StringContains(result, "namespace ArchAngel.Tests", 1);

            map.MatchConstructs(map.GetExactNode(userroot.Namespaces[0]), userroot.Namespaces[0].Classes[0], null, prevroot.Namespaces[0].Classes[0]);
            map.Diff();

            Assert.That(map.ChildNodes[0].ChildNodes, Has.Count(2));
            Assert.That(map.ChildNodes[0].ChildNodes[0].DetermineMissingConstructs(), Is.EqualTo(MissingObject.User | MissingObject.PrevGen));
            Assert.That(map.ChildNodes[0].ChildNodes[1].DetermineMissingConstructs(), Is.EqualTo(MissingObject.NewGen));

            ICodeRoot merged = map.GetMergedCodeRoot();

            result = merged.ToString();
            Assertions.StringContains(result, "class Class1", 2);
            Assertions.StringContains(result, "namespace ArchAngel.Tests", 1);
        }
        public void Matching_Successful()
        {
            CodeRootMap map = new CodeRootMap();

            CodeRoot userroot = CreateBasicRoot();
            map.AddCodeRoot(userroot, Version.User);

            CodeRoot prevroot = CreateBasicRoot();
            map.AddCodeRoot(prevroot, Version.PrevGen);

            CodeRoot templateroot = CreateBasicRoot();
            map.AddCodeRoot(templateroot, Version.NewGen);

            string result = map.GetMergedCodeRoot().ToString();
            Assertions.StringContains(result, "class Class1", 1);
            Assertions.StringContains(result, "namespace ArchAngel.Tests", 1);

            map.MatchConstructs(map.GetExactNode(userroot.Namespaces[0]), userroot.Namespaces[0].Classes[0], null, prevroot.Namespaces[0].Classes[0]);
            map.Diff();

            Assert.That(map.ChildNodes[0].ChildNodes, Has.Count(2));
            Assert.That(map.ChildNodes[0].ChildNodes[0].DetermineMissingConstructs(), Is.EqualTo(MissingObject.User | MissingObject.PrevGen));
            Assert.That(map.ChildNodes[0].ChildNodes[1].DetermineMissingConstructs(), Is.EqualTo(MissingObject.NewGen));

            ICodeRoot merged = map.GetMergedCodeRoot();
            result = merged.ToString();
            Assertions.StringContains(result, "class Class1", 2);
            Assertions.StringContains(result, "namespace ArchAngel.Tests", 1);
        }
        public void Matching_Successful()
        {
            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);

            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);

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

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

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

            map.MatchConstructs(map.GetExactNode(ns), c2, c3, c3);

            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));
        }
        public void Matching_Successful()
        {
            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);

            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);

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

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

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

            map.MatchConstructs(map.GetExactNode(ns), c2, c3, c3);

            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));
        }