public void SingleNameContainsIsIdentified()
        {
            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, this.testProfile);
            var result = cpb.GetPropertyOutput("int", "number1", isReadOnly: false);

            Assert.AreEqual(ReadWriteNumberIntOutput, result);
        }
        public void GetsNonFilteredOutputIfNameDoesntMatch()
        {
            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, this.testProfile);
            var result = cpb.GetPropertyOutput("string", "MyProperty", isReadOnly: false);

            Assert.AreEqual(ReadWriteStringOutput.Replace("$name$", "MyProperty"), result);
        }
        public void ReadWritePropertyIsIdentified()
        {
            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, this.testProfile);
            var result = cpb.GetPropertyOutput("string", "AnotherProperty", isReadOnly: true);

            Assert.AreEqual(ReadonlyStringOutput.Replace("$name$", "AnotherProperty"), result);
        }
        public void SpecificGenericsMatchBeforeWildCard()
        {
            var wildcardGenericsProfile = new Profile
            {
                Name           = "wildcardGenericsProfile",
                ClassGrouping  = "Grid",
                FallbackOutput = "<Fallback />",
                Mappings       = new ObservableCollection <Mapping>
                {
                    new Mapping
                    {
                        Type         = "List<T>",
                        NameContains = "",
                        Output       = "<Wildcard />",
                        IfReadOnly   = false,
                    },
                    new Mapping
                    {
                        Type         = "List<string>",
                        NameContains = "",
                        Output       = "<ListOfStrings />",
                        IfReadOnly   = false,
                    },
                },
            };

            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, wildcardGenericsProfile);
            var result = cpb.GetPropertyOutput("List<string>", "MyProperty", isReadOnly: false);

            Assert.AreEqual("<ListOfStrings />", result);
        }
        public void CanHandleMultipleNumberReplacements()
        {
            var gridProfile = new Profile
            {
                Name              = "GridTestProfile",
                ClassGrouping     = "Grid",
                FallbackOutput    = "<TextBlock Text=\"FALLBACK_$name$\" />",
                SubPropertyOutput = "<TextBlock Text=\"SUBPROP_$name$\" />",
                Mappings          = new ObservableCollection <Mapping>
                {
                    new Mapping
                    {
                        Type         = StringPropertyName,
                        NameContains = "",
                        Output       = "<TextBlock Text=\"$name$\" Grid.Row=\"$incint$\" /><TextBlock Text=\"$name$\" Grid.Row=\"$incint$\" />",
                        IfReadOnly   = false,
                    },
                },
            };

            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, gridProfile);
            var result = cpb.GetPropertyOutput(StringPropertyName, "MyProperty", false);

            var expected = "<TextBlock Text=\"MyProperty\" Grid.Row=\"1\" />" + Environment.NewLine +
                           "<TextBlock Text=\"MyProperty\" Grid.Row=\"2\" />";

            StringAssert.AreEqual(expected, result);
        }
        public void GetFallbackIfTypeNotMapped()
        {
            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, this.testProfile);
            var result = cpb.GetPropertyOutput("bool", "IsAdmin", isReadOnly: false);

            Assert.AreEqual(FallbackOutput, result);
        }
        public void TypeNameIsCaseInsensitive()
        {
            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, this.testProfile);
            var result = cpb.GetPropertyOutput("INT", "number1", isReadOnly: false);

            Assert.AreEqual(ReadWriteNumberIntOutput, result);
        }
        public void ReadOnlyTakesPriorityOverContains()
        {
            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, this.testProfile);
            var result = cpb.GetPropertyOutput("string", "EnteredPwd", isReadOnly: true);

            Assert.AreEqual(ReadonlyStringOutput.Replace("$name$", "EnteredPwd"), result);
        }
        public void MultipleNameContainsIsIdentified()
        {
            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, this.testProfile);
            var result = cpb.GetPropertyOutput("string", "EnteredPassword", isReadOnly: false);

            Assert.AreEqual(ReadWritePasswordStringOutput.Replace("$name$", "EnteredPassword"), result);
        }
Ejemplo n.º 10
0
        public void ReadOnlyPropertiesMatchNotReadOnlyRatherThanFallback()
        {
            var readonlyProfile = new Profile
            {
                Name           = "readonlyProfile",
                ProjectType    = ProjectType.Uwp,
                ClassGrouping  = "Grid",
                FallbackOutput = "<Fallback />",
                Mappings       = new ObservableCollection <Mapping>
                {
                    new Mapping
                    {
                        Type         = StringPropertyName,
                        NameContains = "",
                        Output       = "<ReadAndWrite />",
                        IfReadOnly   = false,
                    },
                },
            };

            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), readonlyProfile.ProjectType, 4, readonlyProfile);
            var result = cpb.GetPropertyOutput(StringPropertyName, "MyProperty", isReadOnly: true);

            Assert.AreEqual("<ReadAndWrite />", result);
        }
        public void CorrectlySplitCamelCasePropertyNames()
        {
            var profile = TestProfile.CreateEmpty();

            profile.Mappings.Add(new Mapping
            {
                Type         = "string",
                IfReadOnly   = false,
                NameContains = string.Empty,
                Output       = "$namewithspaces$",
            });

            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, profile);
            var result = cpb.GetPropertyOutput("string", "MyProperty", isReadOnly: false);

            Assert.AreEqual("My Property", result);
        }
        public void WriteablePropertiesMatchFallbackIfOnlySpecificReadOnlyDefined()
        {
            var readonlyProfile = new Profile
            {
                Name           = "readonlyProfile",
                ClassGrouping  = "Grid",
                FallbackOutput = "<Fallback />",
                Mappings       = new ObservableCollection <Mapping>
                {
                    new Mapping
                    {
                        Type         = StringPropertyName,
                        NameContains = "",
                        Output       = "<ReadOnly />",
                        IfReadOnly   = true,
                    },
                },
            };

            var cpb    = new CodeParserBase(DefaultTestLogger.Create(), 4, readonlyProfile);
            var result = cpb.GetPropertyOutput(StringPropertyName, "MyProperty", isReadOnly: false);

            Assert.AreEqual("<Fallback />", result);
        }