public void TestNextStringUpdateFile()
        {
            string[] lines = File.ReadAllLines("TestNextStringUpdateFile.txt");
            string   path  = Path.GetTempFileName();

            File.WriteAllText(path, lines[0]);
            LocalisationParser parser = new LocalisationParser(path);

            parser.Prefix = "p";

            Assert.IsTrue(parser.NextString());
            Assert.AreEqual("foo", parser.String);
            Assert.AreEqual("P_Foo", parser.FullKey);
            parser.ReplaceStringWithKey();

            Assert.IsTrue(parser.NextString());
            Assert.AreEqual(lines[1], File.ReadAllText(path));
            Assert.AreEqual("bar", parser.String);
            parser.ReplaceStringWithConstant();

            Assert.IsTrue(parser.NextString());
            Assert.AreEqual(lines[2], File.ReadAllText(path));
            Assert.AreEqual("end", parser.String);

            Assert.IsFalse(parser.NextString());
            Assert.AreEqual(lines[3], File.ReadAllText(path));
        }
        public void TestNextString()
        {
            string path = Path.GetTempFileName();

            File.WriteAllText(path, File.ReadAllText("TestNextString.txt"));
            LocalisationParser parser = new LocalisationParser(path);

            parser.Prefix = "p";

            Assert.IsTrue(parser.NextString());
            Assert.AreEqual("some string yay", parser.String);
            Assert.AreEqual("foo", parser.Variable);
            Assert.AreEqual("P_SomeStringYay", parser.FullKey);
            parser.Key = "actually foo";
            Assert.AreEqual("P_ActuallyFoo", parser.FullKey);
            parser.ReplaceStringWithKey();

            Assert.IsTrue(parser.NextString());
            parser.Prefix = "no go";
            Assert.IsTrue(parser.String.Length > 50);
            Assert.AreEqual("foo_bar", parser.Variable);
            Assert.AreEqual("No_go_FooBar", parser.FullKey);
            parser.ReplaceStringWithKey();

            Assert.IsTrue(parser.NextString());
            parser.Prefix = "p!!";
            Assert.AreEqual("good", parser.String);
            Assert.AreEqual("Foo.bar", parser.Variable);
            Assert.AreEqual("P_Good", parser.FullKey);
            parser.ReplaceStringWithConstant();

            Assert.IsTrue(parser.NextString());
            Assert.AreEqual("bad", parser.String);
            Assert.AreEqual("Foo.bar", parser.Variable);
            Assert.AreEqual("P_Bad", parser.FullKey);

            Assert.IsTrue(parser.NextString());
            Assert.AreEqual("escapable", parser.Variable);
            parser.ReplaceStringWithConstant();

            Assert.IsTrue(parser.NextString());
            Assert.AreEqual("unescapable", parser.Variable);
            parser.ReplaceStringWithConstant();

            Assert.IsFalse(parser.NextToken());

            string[] expected = File.ReadAllLines("TestNextStringExpected.txt");
            string[] actual   = File.ReadAllLines(path);
            Assert.AreEqual(expected.Length, actual.Length);
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        public void TestDollarAtStrings()
        {
            LocalisationParser parser = new LocalisationParser("TestDollarAtStrings.txt");

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("as\"\" { as\"d }d", parser.String);
            Assert.AreEqual(TokenType.DollarAtString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("as\\\"\" { as\\\"d }d", parser.String);
            Assert.AreEqual(TokenType.DollarAtString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("as\\\"\"{{ { a{}\r\ns\\\"d }d", parser.String);
            Assert.AreEqual(TokenType.DollarAtString, parser.Type);

            Assert.IsFalse(parser.NextString());
        }
        public void TestDollarStrings()
        {
            LocalisationParser parser = new LocalisationParser("TestDollarStrings.txt");

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("asd", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("\\\"", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("{asd}", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("one {asd} {another.poop} ok {asd}", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("asd{ }", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("sq}}{asdf\"{\"sdf} sdfiuhsdf { sadf }adf}}", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("asd{{", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("asd{{s}", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("asd{asd}", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("asd {{{{  ", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("asd {{{in\"si\"de}}}  ", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual(" { { \"\" } {{ \"\" }} } ", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual("} {asd} asd {{", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsTrue(parser.NextToken());
            Assert.AreEqual(" {{ \\\"", parser.String);
            Assert.AreEqual(TokenType.DollarString, parser.Type);

            Assert.IsFalse(parser.NextString());
        }