public void GetAugmentedParsers_Returns_Parsers() { var parser = new DateTime_Local_Parser(); var resolver = new TypeParserResolver(parser); var parsers = resolver.GetAugmentedParsers(null); Assert.AreEqual(1, parsers.Length); Assert.AreSame(parser, parsers[0]); }
[DataRow("en-GB", "2019-07-01T17:42:32.123+0800", true, "2019-07-01 10:42:32.123 Local")] // If timezone is specified then parser converts to UTC (8 hours ahead of GMT) and then to local (1 hour ahead = overall -7 hours from stated time) public void TryParse_Behaves_Correctly(string culture, string text, bool expectedResult, string expectedValueText) { using (new CultureSwap(culture)) { var parser = new DateTime_Local_Parser(); var actualResult = parser.TryParse(text, out var actualValue); var expectedValue = DataRowParser.DateTime(expectedValueText); Assert.AreEqual(expectedResult, actualResult); Assert.AreEqual(expectedValue, actualValue); Assert.AreEqual(expectedValue?.Kind, actualValue.Kind); } }
public void GetAugmentedParsers_Augments_Registered_Parsers_With_List_Passed_In() { var originalDateTimeParser = new DateTime_Local_Parser(); var originalDateTimeOffsetParser = new DateTimeOffset_Invariant_Parser(); var newDateTimeParser = new DateTime_Iso8601_Parser(); var newByteArrayParser = new ByteArray_Mime64_Parser(); var resolver = new TypeParserResolver(originalDateTimeParser, originalDateTimeOffsetParser); var parsers = resolver.GetAugmentedParsers(newDateTimeParser, null, newByteArrayParser); Assert.AreEqual(3, parsers.Length); Assert.IsTrue(parsers.Contains(newDateTimeParser)); Assert.IsTrue(parsers.Contains(originalDateTimeOffsetParser)); Assert.IsTrue(parsers.Contains(newByteArrayParser)); var originalParsers = resolver.GetParsers(); Assert.AreEqual(2, originalParsers.Length); Assert.IsTrue(originalParsers.Contains(originalDateTimeParser)); Assert.IsTrue(originalParsers.Contains(originalDateTimeOffsetParser)); }