private ILocanReader GetReaderForFilepath(string filepath) { if (string.IsNullOrEmpty(filepath)) { throw new ArgumentNullException("filepath"); } ILocanReader reader = null; System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(Consts.ResxRegexPattern); if (r.IsMatch(filepath)) { reader = new ResxFileLocanReader(filepath); } return(reader); }
public void TestReader01() { string filepath = this.WriteTextToTempFile(Consts.ResxSample01); using (ILocanReader reader = new ResxFileLocanReader(filepath)) { Dictionary<string, string> expectedValues = new Dictionary<string, string>(); expectedValues.Add("Key01", "Value01"); expectedValues.Add("Key02", "Value02"); expectedValues.Add("Key03", "Value03"); int currentIndex = 0; foreach (ILocanRow row in reader.GetRowsToBeTranslated()) { string expectedKey = expectedValues.ElementAt(currentIndex).Key; string expectedValue = expectedValues.ElementAt(currentIndex).Value as string; Assert.AreEqual(expectedKey, row.Id); Assert.AreEqual(expectedValue, row.StringToTranslate); currentIndex++; } } }
private ILocanReader GetReaderForFilepath(string filepath) { if (string.IsNullOrEmpty(filepath)) { throw new ArgumentNullException("filepath"); } ILocanReader reader = null; System.Text.RegularExpressions.Regex r = new System.Text.RegularExpressions.Regex(Consts.ResxRegexPattern); if (r.IsMatch(filepath)) { reader = new ResxFileLocanReader(filepath); } return reader; }