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); }
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); }
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); }
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()); }
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); }