예제 #1
0
        public void UnescapeString_WithBackSlash_HasNoBackslash()
        {
            const string contents = @"don\'t want backslash";
            const string expected = @"don't want backslash";

            string actual = MakePot.UnescapeString(contents);

            Assert.AreEqual(expected, actual);
        }
예제 #2
0
            public string MakePotFile(string input)
            {
                string csharpFilePath = System.IO.Path.Combine(Path, "csharp.cs");

                File.WriteAllText(csharpFilePath, input);

                var pot = new MakePot();

                pot.OutputFile  = System.IO.Path.Combine(Path, "output.pot");
                pot.CSharpFiles = EnvironmentForTest.CreateTaskItemsForFilePath(csharpFilePath);
                pot.Execute();

                return(File.ReadAllText(pot.OutputFile));
            }
예제 #3
0
        public void MatchesInCSharpString_StringWithTilde_HasMatch()
        {
            string contents = @"
somevar.MyLocalizableFunction('~MyLocalizableString');
".Replace("'", "\"");

            var             pot     = new MakePot();
            MatchCollection matches = pot.MatchesInCSharpString(contents);

            Assert.AreEqual(1, matches.Count);
            foreach (Match match in matches)
            {
                Assert.AreEqual(3, match.Groups.Count);
                Assert.AreEqual("MyLocalizableString", match.Groups["key"].Value);
            }
        }
예제 #4
0
        public void MatchesInCSharpString_UsingTextEqual_HasMatchAndNotes()
        {
            string contents = @"
somevar.Text = 'MyLocalizableString';
".Replace("'", "\"");

            var             pot     = new MakePot();
            MatchCollection matches = pot.MatchesInCSharpString(contents);

            Assert.AreEqual(1, matches.Count);
            foreach (Match match in matches)
            {
                Assert.AreEqual(3, match.Groups.Count);
                Assert.AreEqual("MyLocalizableString", match.Groups["key"].Value);
            }
        }
예제 #5
0
        public void MatchesInCSharpString_StringWithTwoMatches_DoesntContainTildeInResult()
        {
            string contents = @"
somevar.MyLocalizableFunction(StringCatalog.Get('~MyLocalizableString', 'MyTranslationNotes'));
".Replace("'", "\"");

            var             pot     = new MakePot();
            MatchCollection matches = pot.MatchesInCSharpString(contents);

            Assert.AreEqual(1, matches.Count);
            foreach (Match match in matches)
            {
                Assert.AreEqual(3, match.Groups.Count);
                Assert.AreEqual("MyLocalizableString", match.Groups["key"].Value);
                Assert.AreEqual("MyTranslationNotes", match.Groups["note"].Value);
            }
        }
예제 #6
0
        public void MatchesInCSharpString_UsingStringCatalogGetFormattedNoTilde_HasMatchAndNotes()
        {
            string contents = @"
somevar.MyLocalizableFunction(StringCatalog.GetFormatted('MyLocalizableString {0}', 'MyTranslationNotes', someArg));
".Replace("'", "\"");

            var             pot     = new MakePot();
            MatchCollection matches = pot.MatchesInCSharpString(contents);

            Assert.AreEqual(1, matches.Count);
            foreach (Match match in matches)
            {
                Assert.AreEqual(3, match.Groups.Count);
                Assert.AreEqual("MyLocalizableString {0}", match.Groups["key"].Value);
                Assert.AreEqual("MyTranslationNotes", match.Groups["note"].Value);
            }
        }
예제 #7
0
        public void MatchesInCSharpString_StringWithBackslashQuote_MatchesToEndOfString()
        {
            string contents = @"
somevar.Text = 'MyLocalizableString \'InQuote\' end';
".Replace("'", "\"");

            string expected = "MyLocalizableString \\\"InQuote\\\" end";

            var             pot     = new MakePot();
            MatchCollection matches = pot.MatchesInCSharpString(contents);

            Assert.AreEqual(1, matches.Count);
            foreach (Match match in matches)
            {
                Assert.AreEqual(3, match.Groups.Count);
                Assert.AreEqual(expected, match.Groups["key"].Value);
            }
        }