public void TestWriter01() { List<ILocanRow> expectedValues = new List<ILocanRow> { new LocanRow(id:"Key01",translatedString:"Value01"), new LocanRow(id:"Key02",translatedString:"Value02"), new LocanRow(id:"Key03",translatedString:"Value03"), }; string filepath = this.GetTempFilename(true, ".resx"); using (ResxFileLocanWriter writer = new ResxFileLocanWriter(filepath)) { writer.WriteRows(expectedValues); } // now we need to read that file using (ResXResourceReader reader = new ResXResourceReader(filepath)) { int currentIndex = 0; foreach (DictionaryEntry de in reader) { string expectedKey = expectedValues[currentIndex].Id; string expectedValue = expectedValues[currentIndex].TranslatedString; Assert.AreEqual(expectedKey, de.Key); Assert.AreEqual(expectedValue, de.Value); currentIndex++; } } }
private ILocanWriter GetWriterForFilepath(string filepath) { if (string.IsNullOrEmpty(filepath)) { throw new ArgumentNullException("filepath"); } ILocanWriter writer = null; System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(Consts.ResxRegexPattern); if (r.IsMatch(filepath)) { writer = new ResxFileLocanWriter(filepath); } return(writer); }
private ILocanWriter GetWriterForFilepath(string filepath) { if (string.IsNullOrEmpty(filepath)) { throw new ArgumentNullException("filepath"); } ILocanWriter writer = null; System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(Consts.ResxRegexPattern); if (r.IsMatch(filepath)) { writer = new ResxFileLocanWriter(filepath); } return writer; }