Ejemplo n.º 1
0
        private void AssertInvalidRelativeDateTimeComponent(string input, DateTime baseDate)
        {
            var components      = RelativeDateTimeComponent.GetComponentsFromText(input);
            var componentPeriod = components.Select(c => c.GetTimePeriod(baseDate)).FirstOrDefault();

            Assert.IsNull(componentPeriod);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
0
        private void AssertValidRelativeDateTimeComponent(ITimePeriod expected, string input, DateTime baseDate)
        {
            var components = RelativeDateTimeComponent.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);
        }