public void ValidationReportsNoErrorsOnNewDocument() { var document = new XlfDocument(); document.LoadNew("cs"); var validationErrors = GetValidationErrors(document); Assert.Empty(validationErrors); }
public void LoadNewInitializesNewDocumentWithCorrectContent() { var xliffDocument = new XlfDocument(); xliffDocument.LoadNew("es"); var writer = new StringWriter(); xliffDocument.Save(writer); string expected = @"<xliff xmlns=""urn:oasis:names:tc:xliff:document:1.2"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" version=""1.2"" xsi:schemaLocation=""urn:oasis:names:tc:xliff:document:1.2 xliff-core-1.2-transitional.xsd""> <file datatype=""xml"" source-language=""en"" target-language=""es"" original=""_""> <body /> </file> </xliff>"; Assert.Equal(expected, writer.ToString()); }
internal XlfDocument LoadXlfDocument(string path, string language = null, bool createIfNonExistent = false) { var document = new XlfDocument(); if (File.Exists(path)) { document.Load(path); } else if (createIfNonExistent) { Release.Assert(!string.IsNullOrEmpty(language)); document.LoadNew(language); } else { throw new FileNotFoundException($"File not found: {path}", path); } return(document); }
private static string Update(string xliff, string resx) { var xliffDocument = new XlfDocument(); if (string.IsNullOrEmpty(xliff)) { xliffDocument.LoadNew("fr"); } else { xliffDocument.Load(new StringReader(xliff)); } var resxDocument = new ResxDocument(); resxDocument.Load(new StringReader(resx)); xliffDocument.Update(resxDocument, "test.resx"); var writer = new StringWriter(); xliffDocument.Save(writer); return(writer.ToString()); }