private void AssertInvalidTimeComponent(string input, DateTime baseDate)
        {
            var components      = TimeComponent.GetComponentsFromText(input);
            var componentPeriod = components.Select(c => c.GetTimePeriod(baseDate)).FirstOrDefault();

            Assert.IsNull(componentPeriod);
        }
Beispiel #2
0
        private IEnumerable <TemporalComponent> GetComponentsFromText(string text)
        {
            var components = new List <TemporalComponent>();

            var dateComponents = DateComponent.GetComponentsFromText(text);

            components.AddRange(dateComponents);

            var timeComponents = TimeComponent.GetComponentsFromText(text);

            components.AddRange(timeComponents);

            var sequenceComponents = SequenceComponent.GetComponentsFromText(text);

            components.AddRange(sequenceComponents);

            var fuzzyComponents = FuzzyComponent.GetComponentsFromText(text);

            components.AddRange(fuzzyComponents);

            var durationComponents = DurationComponent.GetComponentsFromText(text);

            components.AddRange(durationComponents);

            var relativeComponents = RelativeDateTimeComponent.GetComponentsFromText(text);

            components.AddRange(relativeComponents);

            return(components);
        }
        private void AssertValidTimeComponent(ITimePeriod expected, string input, DateTime baseDate)
        {
            var components = TimeComponent.GetComponentsFromText(input);

            Assert.IsTrue(components.Any());
            var componentPeriod = components.FirstOrDefault().GetTimePeriod(baseDate);

            Assert.IsNotNull(componentPeriod);
            Assert.AreEqual(expected.Start, componentPeriod.Start);
            Assert.AreEqual(expected.End, componentPeriod.End);
        }