public void Test_Execution_Expect_Calculation_For_Input() { List<DateTimeRangeCalculatorBase> calculators = new List<DateTimeRangeCalculatorBase> { new MockImplementationTodayCalculator { DateTimeProvider = _mockDateTimeProvider.Object } }; _mockDateTimeProvider .SetupGet(expression: m => m.Today) .Returns(value: new DateTime(year: 1986, month: 4, day: 11)); DateTimeRangeParser rangeExtractor2 = new DateTimeRangeParser( dateTimeProvider: _mockDateTimeProvider.Object, calculators: calculators); DateTimeRange actual = rangeExtractor2.Parse(input: "Today"); DateTimeRange expected = new DateTimeRange { Start = new DateTime(year: 1986, month: 4, day: 11), End = new DateTime(year: 1986, month: 4, day: 11) }; Assert.Equal( expected: expected, actual: actual); }
public static void Main(string[] args) { DateTimeRangeParser parser = new DateTimeRangeParser(); foreach (var item in parser.ImplementedCalculations) { Console.WriteLine(item); if (item.Examples != null) { foreach (CalculationExample example in item.Examples) { Console.WriteLine($" - Input: \"{example.InputString}\" results value: {parser.Parse(input: example.InputString)}"); } } } }
public void Test_Execution_Expect_SelectorNames() { List<DateTimeRangeCalculatorBase> calculators = new List<DateTimeRangeCalculatorBase> { new MockImplementationTodayCalculator { DateTimeProvider = _mockDateTimeProvider.Object } }; _mockDateTimeProvider .SetupGet(expression: m => m.Today) .Returns(value: new DateTime(year: 1986, month: 4, day: 11)); DateTimeRangeParser rangeExtractor2 = new DateTimeRangeParser( dateTimeProvider: _mockDateTimeProvider.Object, calculators: calculators); ReadOnlyCollection<string> expectedSelectorNames = new List<string> { "Today" }.AsReadOnly(); Assert.Equal( expected: expectedSelectorNames, actual: rangeExtractor2.ImplementedCalculatorNames); }
public static DateTimeRangeParser EnableCaching(this DateTimeRangeParser dateTimeRangeParser) { dateTimeRangeParser.CachingEnabled = true; return(dateTimeRangeParser); }