예제 #1
0
        public void NullTest(string text)
        {
            var results = extractor.Extract(text);

            Assert.AreEqual(0, results.Count);
            TestWriter.Write(TestCulture.Chinese, extractor, text);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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());
        }
예제 #4
0
        public void BasicTestNone(string text)
        {
            var results = extractor.Extract(text);

            Assert.AreEqual(0, results.Count);
            TestWriter.Write(TestCulture.English, extractor, text);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
        }
예제 #9
0
        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);
        }
예제 #10
0
        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);
        }
예제 #11
0
        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);
        }
예제 #12
0
        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);
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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);
        }
예제 #17
0
        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);
        }
예제 #18
0
        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);
        }
예제 #19
0
        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);
        }
예제 #20
0
        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);
        }
예제 #21
0
        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);
        }
예제 #22
0
        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);
        }
예제 #23
0
        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);
        }
예제 #24
0
        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);
        }
예제 #25
0
        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);
        }
예제 #26
0
        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);
            }
        }
예제 #27
0
        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);
        }
예제 #28
0
        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);
        }
예제 #29
0
        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);
        }
예제 #30
0
        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);
        }