public void NullTest(string text) { var results = extractor.Extract(text); Assert.AreEqual(0, results.Count); TestWriter.Write(TestCulture.Chinese, extractor, text); }
private void MultiTest(IModel model, string source, int count) { var result = model.Parse(source); Assert.AreEqual(count, result.Count); TestWriter.Write(TestCulture.Spanish, model, source, result); }
public void TestColourClearing() { const OmniColours colour = OmniColours.BrightCyan; var initialColour = TestWriter.GetDecoration(); TestWriter.SetDecoration(new OmniDecoration(colour)); TestWriter.Write("Test01"); AssertLastColour(colour); TestWriter.Write("Test02"); AssertLastColour(colour); TestWriter.ClearDecoration(); AssertLastColour(initialColour); TestWriter.Write(colour, "Test03"); AssertLastColour(initialColour); TestWriter.WriteLine("Test04"); AssertLastColour(initialColour); var message = new ColourMessage(); message.SetDecoration(new OmniDecoration(colour)); message.AppendLine("Test05"); TestWriter.Write(message); AssertEqual(initialColour, TestColours.Last()); }
public void BasicTestNone(string text) { var results = extractor.Extract(text); Assert.AreEqual(0, results.Count); TestWriter.Write(TestCulture.English, extractor, text); }
private void MultiTest(IModel model, string source, int count) { var resultStr = model.Parse(source); var resultJson = resultStr; Assert.AreEqual(count, resultJson.Count); TestWriter.Write(TestCulture.English, model, source, resultStr); }
public void BasicTest(string text, string expectedOutput) { var results = extractor.Extract(text); Assert.AreEqual(1, results.Count); Assert.AreEqual(expectedOutput, results[0].Text); TestWriter.Write(TestCulture.English, extractor, text, results); }
private void BasicTest(IModel model, string source, string value) { var resultStr = model.Parse(source); var resultJson = resultStr; Assert.AreEqual(1, resultJson.Count); Assert.AreEqual(value, resultJson.First().Resolution["value"] + " " + resultJson.First().Resolution["unit"]); TestWriter.Write(TestCulture.Chinese, model, source, resultStr); }
public void BasicTest(string text) { var results = extractor.Extract(text); Assert.AreEqual(1, results.Count); Assert.AreEqual(results[0].Text, text); Assert.AreEqual(Constants.SYS_DATETIME_TIMEPERIOD, results[0].Type); TestWriter.Write(TestCulture.Chinese, extractor, text, results); }
private void BasicTest(IModel model, string source, string value, string text = null) { var result = model.Parse(source); Assert.AreEqual(1, result.Count); Assert.AreEqual(text ?? source.Trim(), result[0].Text); Assert.AreEqual(value, result[0].Resolution["value"]); TestWriter.Write(TestCulture.Spanish, model, source, result); }
public void BasicTest(string text, int start, int length) { var results = extractor.Extract(text); Assert.AreEqual(1, results.Count); Assert.AreEqual(start, results[0].Start); Assert.AreEqual(length, results[0].Length); TestWriter.Write(TestCulture.Spanish, extractor, text, results); }
public void BasicTest(string text, string type) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], referenceDate); Assert.AreEqual(type, pr.Type.Replace("datetimeV2.", "")); TestWriter.Write(TestCulture.English, parser, referenceDate, text, pr); }
private void WrappedTest(IModel model, string source, string extractSrc, string value) { var resultStr = model.Parse(source); var resultJson = resultStr; Assert.AreEqual(1, resultJson.Count); Assert.AreEqual(extractSrc, resultJson[0].Text); Assert.AreEqual(value, resultJson[0].Resolution["value"]); TestWriter.Write(TestCulture.English, model, source, resultStr); }
private void BasicTest(IModel model, string source, string[] values) { var results = model.Parse(source); Assert.AreEqual(values.Length, results.Count); var resultsValues = results.Select(x => GetStringValue(x)).ToArray(); CollectionAssert.AreEqual(values, resultsValues); TestWriter.Write(TestCulture.Chinese, model, source, results); }
public void BasicTest(string text) { var results = extractor.Extract(text); Assert.AreEqual(1, results.Count); Assert.AreEqual(0, results[0].Start); Assert.AreEqual(text.Length, results[0].Length); Assert.AreEqual(Constants.SYS_DATETIME_DURATION, results[0].Type); TestWriter.Write(TestCulture.Chinese, extractor, text, results); }
private void BasicTest(IModel model, string source, string value) { var resultStr = model.Parse(source); var resultJson = resultStr; Assert.AreEqual(1, resultJson.Count); Assert.AreEqual(source.Trim(), resultJson[0].Text); Assert.AreEqual(value, resultJson[0].Resolution["value"]); TestWriter.Write(TestCulture.French, model, source, resultStr); }
public void BasicTest(string text, int start, int length) { var results = extractor.Extract(text); Assert.AreEqual(1, results.Count); Assert.AreEqual(start, results[0].Start); Assert.AreEqual(length, results[0].Length); Assert.AreEqual(Constants.SYS_DATETIME_TIMEPERIOD, results[0].Type); TestWriter.Write(TestCulture.English, extractor, text, results); }
public void BasicTest(string text, DateObject date) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0]); Assert.AreEqual(Constants.SYS_DATETIME_TIME, pr.Type); Assert.AreEqual(date, ((DateTimeResolutionResult)pr.Value).FutureValue); TestWriter.Write(TestCulture.English, parser, text, pr); }
public void BasicTestResolution(string text, string resolution, DateObject refDate) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], refDate); var prValue = (List <Dictionary <string, string> >)(((SortedDictionary <string, object>)pr.Value).First().Value); Assert.AreEqual(resolution, prValue.First()["value"]); TestWriter.Write(TestCulture.English, parser, refDate, text, pr); }
public void BasicTest(string text, string timex) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], refTime); Assert.AreEqual(Constants.SYS_DATETIME_DATE, pr.Type); Assert.AreEqual(timex, ((DateTimeResolutionResult)pr.Value).Timex); TestWriter.Write(TestCulture.Chinese, parser, refTime, text, pr); }
public void BasicTest(string text, string luisValueStr) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], referenceTime); Assert.AreEqual(Constants.SYS_DATETIME_DATETIMEPERIOD, pr.Type); Assert.AreEqual(luisValueStr, ((DateTimeResolutionResult)pr.Value).Timex); TestWriter.Write(TestCulture.Spanish, parser, referenceTime, text, pr); }
public void BasicTest(string text, string expected) { var pr = model.Parse(text); Assert.AreEqual(1, pr.Count); Assert.AreEqual(expected, pr[0].Text); var values = pr[0].Resolution["values"] as IEnumerable <Dictionary <string, string> >; Assert.AreEqual(Constants.SYS_DATETIME_DATETIME, values.First()["type"]); TestWriter.Write(TestCulture.English, model, System.DateTime.Now, text, pr); }
public void BasicTest(string text, DateObject futreTime, DateObject pastTime) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], refTime); Assert.AreEqual(Constants.SYS_DATETIME_DATETIME, pr.Type); Assert.AreEqual(futreTime, ((DateTimeResolutionResult)pr.Value).FutureValue); Assert.AreEqual(pastTime, ((DateTimeResolutionResult)pr.Value).PastValue); TestWriter.Write(TestCulture.Chinese, parser, refTime, text, pr); }
public void BasicTest(string text, DateObject beginDate, DateObject endDate) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], referenceTime); Assert.AreEqual(Constants.SYS_DATETIME_TIMEPERIOD, pr.Type); Assert.AreEqual(beginDate, ((Tuple <DateObject, DateObject>)((DateTimeResolutionResult)pr.Value).FutureValue).Item1); Assert.AreEqual(endDate, ((Tuple <DateObject, DateObject>)((DateTimeResolutionResult)pr.Value).FutureValue).Item2); TestWriter.Write(TestCulture.English, parser, referenceTime, text, pr); }
public void BasicTest(string text, string value, string luisValue) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], System.DateTime.Now); Assert.AreEqual(Constants.SYS_DATETIME_SET, pr.Type); Assert.AreEqual(value, ((DateTimeResolutionResult)pr.Value).FutureValue); Assert.AreEqual(luisValue, pr.TimexStr); TestWriter.Write(TestCulture.Spanish, parser, text, pr); }
public void BasicTest(string text, double value, string luisValue) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], referenceDate); Assert.AreEqual(Constants.SYS_DATETIME_DURATION, pr.Type); Assert.AreEqual(value, ((DateTimeResolutionResult)pr.Value).FutureValue); Assert.AreEqual(luisValue, ((DateTimeResolutionResult)pr.Value).Timex); TestWriter.Write(TestCulture.English, parser, referenceDate, text, pr); }
public void BasicTestWithOptions(string text, int count, DateTimeOptions options = DateTimeOptions.None) { IExtractor extractorWithOptions = new BaseMergedExtractor(new EnglishMergedExtractorConfiguration(), options); var results = extractorWithOptions.Extract(text); Assert.AreEqual(count, results.Count); if (options.Equals(DateTimeOptions.None)) { TestWriter.Write(TestCulture.English, extractor, text, results); } else { TestWriter.Write(TestCulture.English, "BaseMergedExtractorSkipFromTo", text, results); } }
public void BasicTest(DateTimeModel model, DateObject baseDateTime, string text, string expectedType, string expectedString, string expectedTimex) { var results = model.Parse(text, baseDateTime); Assert.AreEqual(1, results.Count); var result = results.First(); Assert.AreEqual(expectedString, result.Text); var values = result.Resolution["values"] as IEnumerable <Dictionary <string, string> >; Assert.AreEqual(expectedType, values.First()["type"]); Assert.AreEqual(expectedTimex, values.First()["timex"]); TestWriter.Write(TestCulture.Chinese, model, baseDateTime, text, results); }
public void BasicTestWithTwoResults(string text, string type1, string type2) { var er = extractor.Extract(text); Assert.AreEqual(2, er.Count); var pr = parser.Parse(er[0], referenceDate); Assert.AreEqual(type1, pr.Type.Replace("datetimeV2.", "")); pr = parser.Parse(er[1], referenceDate); Assert.AreEqual(type2, pr.Type.Replace("datetimeV2.", "")); var erArray = extractor.Extract(text); TestWriter.Write(TestCulture.English, parser, referenceDate, text, erArray.Select(o => parser.Parse(o, referenceDate))); // TODO multiple dates // TestWriter.Write(TestCulture.English, parser, refrenceDate, text, pr); }
public void BasicTest(string text, int start, int length, int expected = 1) { var results = extractor.Extract(text); Assert.AreEqual(expected, results.Count); if (expected < 1) { TestWriter.Write(TestCulture.Spanish, extractor, text); return; } Assert.AreEqual(start, results[0].Start); Assert.AreEqual(length, results[0].Length); Assert.AreEqual(Constants.SYS_DATETIME_TIME, results[0].Type); TestWriter.Write(TestCulture.Spanish, extractor, text, results); }
public void BasicTestFuture(string text, int beginDay, int endDay, int month, int year) { var er = extractor.Extract(text); Assert.AreEqual(1, er.Count); var pr = parser.Parse(er[0], referenceDate); Assert.AreEqual(Constants.SYS_DATETIME_DATEPERIOD, pr.Type); var beginDate = new DateObject(year, month, beginDay); Assert.AreEqual(beginDate, ((Tuple <DateObject, DateObject>)((DateTimeResolutionResult)pr.Value).FutureValue).Item1); var endDate = new DateObject(year, month, endDay); Assert.AreEqual(endDate, ((Tuple <DateObject, DateObject>)((DateTimeResolutionResult)pr.Value).FutureValue).Item2); TestWriter.Write(TestCulture.Spanish, parser, referenceDate, text, pr); }