Example #1
0
 private Enumeration(Enumeration enumToCopyFrom)
     : base(null)
 {
     enumToCopyFrom.CloneInto(this);
     foreach (string mod in enumToCopyFrom.Modifiers)
     {
         Modifiers.Add(mod);
     }
     EnumBase = enumToCopyFrom.EnumBase;
 }
        public void Enumeration()
        {
            Enumeration item = new Enumeration(controller, "FileTypes");
            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("FileTypes"));

            Class cl = new Class(controller, "Class1");
            cl.AddChild(item);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.FileTypes"));
        }
 public VBEnumMember(Enumeration.EnumMember obj)
 {
     this.obj = obj;
 }
 public VBEnumerationPrinter(Enumeration obj)
 {
     this.obj = obj;
 }
        public void Enumeration_Changed_Modifier()
        {
            const string enumName = "MyEnumerationName1";
            string expectedResult = String.Format("{0} enum {1}", Modifier2, enumName);

            Enumeration merged1 = new Enumeration(controller, enumName);
            Enumeration merged2 = new Enumeration(controller, enumName);
            Enumeration merged3 = new Enumeration(controller, enumName);

            Enumeration changing = new Enumeration(controller, enumName);
            changing.Modifiers.Add(Modifier2);
            Enumeration unchanging = new Enumeration(controller, enumName);
            unchanging.Modifiers.Add(Modifier1);

            Merge_And_Assert(merged1, merged2, merged3, changing, unchanging, expectedResult);
        }
        public void EnumMember()
        {
            Enumeration en = new Enumeration(controller, "FileTypes");
            Enumeration.EnumMember item = new Enumeration.EnumMember(controller, "CSharp");
            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("CSharp"));
            en.AddChild(item);

            Class cl = new Class(controller, "Class1");
            cl.AddChild(en);

            Assert.That(item.FullyQualifiedDisplayName, Is.EqualTo("Class1.FileTypes.CSharp"));
        }
        public void Enumeration()
        {
            Enumeration inter = new Enumeration(controller);
            inter.Name = "File";
            inter.Modifiers.Add("public");
            inter.Members.Add(new Enumeration.EnumMember(controller, "Read"));
            inter.Members.Add(new Enumeration.EnumMember(controller, "Write"));

            Assert.That(inter.IsTheSame(inter.Clone(), ComparisonDepth.Outer), Is.True);
            Assert.That(inter.Clone().WalkChildren(), Has.Count(0));
        }
Example #8
0
        private bool IsTheSame(Enumeration comparisonEnum, ComparisonDepth depth)
        {
            if (comparisonEnum == null)
                return false;

            if (Name == comparisonEnum.Name)
            {
                if ((ParentObject == null && comparisonEnum.ParentObject == null) ||
                    (ParentObject.GetType() == comparisonEnum.ParentObject.GetType() &&
                    ParentObject.Name == comparisonEnum.ParentObject.Name))
                {
                    if (depth == ComparisonDepth.Signature)
                    {
                        return true;
                    }

                    if (!base.IsTheSame(comparisonEnum, depth))
                    {
                        return false;
                    }

                    if (!Utility.StringCollectionsAreTheSame(Modifiers, comparisonEnum.Modifiers))
                    {
                        ComparisonDifference += GetType().Name + ".Modifiers";
                        return false;
                    }

                    if (depth == ComparisonDepth.Outer)
                    {
                        return true;
                    }

                    // Now check all child objects
                    Comparers.BaseConstructComparer comparer = new Comparers.BaseConstructComparer();

                    if (EnumBase != comparisonEnum.EnumBase)
                    {
                        return false;
                    }
                    if (!ArchAngel.Providers.CodeProvider.CSharp.Utility.BaseContructCollectionsAreTheSame(Members.ToArray(), comparisonEnum.Members.ToArray(), comparer))
                    {
                        ComparisonDifference += GetType().Name + ".Members";
                        return false;
                    }
                    return true;
                }
            }
            return false;
        }
Example #9
0
 private bool IsTheSame(Enumeration comparisonEnum)
 {
     return IsTheSame(comparisonEnum, ComparisonDepth.Signature);
 }
Example #10
0
        private void Process_Enum_Declaration(TypeMemberDeclaration node)
        {
            if (node == null)
                throw new ArgumentNullException("node");
            Enumeration enu = new Enumeration(controller);
            enu.Modifiers.AddRange(FormatterUtility.GetModifiersFromEnum(node.Modifiers));
            enu.Name = node.Name.Text;

            SetupBaseConstruct(node, enu);
        }
        public void Enumeration()
        {
            Enumeration inter = new Enumeration(controller);
            inter.Name = "File";
            inter.Modifiers.Add("public");
            inter.Members.Add(new Enumeration.EnumMember(controller, "Read"));
            inter.Members.Add(new Enumeration.EnumMember(controller, "Write"));

            CodeRoot root = CreateClassAndNamespace(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()));
            Assert.That(result.Contains("Read"), Is.True, "Contains Read enum value");
            Assert.That(result.Contains("Write"), Is.True, "Contains Write enum value");
            Assertions.StringContains(result, "class Class1");
            Assertions.StringContains(result, "[Serializable(true)]");
            Assertions.StringContains(result, "namespace ArchAngel.Tests");
            Assertions.StringContains(result, "Read");
            Assertions.StringContains(result, "Write");
            Assertions.StringContains(result, "public enum File");
        }