Пример #1
0
        public void ShouldLeaveTheFileUntouchedWhenUsingAnIdentityTransformation()
        {
            using (var inputStream = new FileStream(Test1FileName, FileMode.Open, FileAccess.Read))
                using (var outputStream = new FileStream(OutputFileName, FileMode.Create, FileAccess.Write))
                {
                    var processor = new POProcessor("en");
                    processor.Transform(inputStream, outputStream);
                }

            FileAssert.AreEqual(Test1FileName, OutputFileName);
        }
Пример #2
0
        public void ShouldAddFunnyAccentsWhenTransformingWithTheAccenterTransformation()
        {
            using (var inputStream = new FileStream(Test1FileName, FileMode.Open, FileAccess.Read))
                using (var outputStream = new FileStream(OutputFileName, FileMode.Create, FileAccess.Write))
                {
                    var processor = new POProcessor("qps-Ploc");
                    processor.TransformString += (_, e) => e.Value = Accents.Instance.Transform(e.Value);
                    processor.Transform(inputStream, outputStream);
                }

            FileAssert.AreEqual("Accents.po", OutputFileName);
        }
Пример #3
0
        public void ShouldReverseStringsButLeaveTheCommentsUntouchedWhenTransformingWithAStringReverseTransformation()
        {
            using (var inputStream = new FileStream(Test1FileName, FileMode.Open, FileAccess.Read))
                using (var outputStream = new FileStream(OutputFileName, FileMode.Create, FileAccess.Write))
                {
                    var processor = new POProcessor("qps-Ploc");
                    processor.TransformString += (_, e) => e.Value = Mirror.Instance.Transform(e.Value);
                    processor.Transform(inputStream, outputStream);
                }

            FileAssert.AreEqual("Mirror.po", OutputFileName);
        }
Пример #4
0
        public void ShouldThrowForBadInputFile()
        {
            POFileFormatException ex;

            using (var inputStream = new FileStream(Test2FileName, FileMode.Open, FileAccess.Read))
                using (var outputStream = new FileStream(OutputFileName, FileMode.Create, FileAccess.Write))
                {
                    var processor = new POProcessor("qps-Ploc");
                    ex = Assert.Throws <POFileFormatException>(() => processor.Transform(inputStream, outputStream));
                }

            Assert.AreEqual("Entry beginning at 18,1 must not have an empty id." + Environment.NewLine, ex.Message);
            Assert.AreEqual("Entry beginning at 18,1 must not have an empty id.", ex.DiagnosticMessages.First());
        }
Пример #5
0
        public void ShouldApplyMultipleTransformations()
        {
            using (var inputStream = new FileStream(Test1FileName, FileMode.Open, FileAccess.Read))
                using (var outputStream = new FileStream(OutputFileName, FileMode.Create, FileAccess.Write))
                {
                    var processor = new POProcessor("qps-Ploc");
                    processor.TransformString += (_, e) => e.Value += "1";
                    processor.TransformString += (_, e) => e.Value = Brackets.Instance.Transform(e.Value);
                    processor.TransformString += (_, e) => e.Value += "2";
                    processor.Transform(inputStream, outputStream);
                }

            FileAssert.AreEqual("Multiple.po", OutputFileName);
        }