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 AssertValidFuzzyComponent(ITimePeriod expected, string input, DateTime baseDate) { var components = FuzzyComponent.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); }
public void GetTimeOfDayPeriodTest() { var morning = new TimeRange(BaseDate, new TimeSpan(12, 0, 0)); Assert.AreEqual(morning, FuzzyComponent.GetTimeOfDayPeriod(TimeOfDay.Morning, BaseDate)); var afternoon = new TimeRange(BaseDate.AddHours(12), new TimeSpan(6, 0, 0)); Assert.AreEqual(afternoon, FuzzyComponent.GetTimeOfDayPeriod(TimeOfDay.Afternoon, BaseDate)); var night = new TimeRange(BaseDate.AddHours(18), new TimeSpan(6, 0, 0)); Assert.AreEqual(night, FuzzyComponent.GetTimeOfDayPeriod(TimeOfDay.Night, BaseDate)); }