public void Format_Behaves_Correctly(string rawValue, string expected) { using (new CultureSwap("en-GB")) { var value = DataRowParser.DateTimeOffset(rawValue).Value; var formatter = new DateTimeOffset_JavaScriptTicks_Formatter(); var actual = formatter.Format(value); Assert.AreEqual(expected, actual); } }
public void GetFormatters_Returns_Collection_Of_All_Registered_Formatters() { var formatter1 = new DateTime_Iso8601_Formatter(); var formatter2 = new DateTimeOffset_JavaScriptTicks_Formatter(); var resolver = new TypeFormatterResolver(formatter1, formatter2); var formatters = resolver.GetFormatters(); Assert.AreEqual(2, formatters.Length); Assert.IsTrue(formatters.Contains(formatter1)); Assert.IsTrue(formatters.Contains(formatter2)); }
public void GetAugmentedFormatters_Augments_Registered_Formatters_With_List_Passed_In() { var originalDateTimeFormatter = new DateTime_JavaScriptTicks_Formatter(); var originalDateTimeOffsetFormatter = new DateTimeOffset_JavaScriptTicks_Formatter(); var newDateTimeFormatter = new DateTime_Iso8601_Formatter(); var newByteArrayFormatter = new ByteArray_Mime64_Formatter(); var resolver = new TypeFormatterResolver(originalDateTimeFormatter, originalDateTimeOffsetFormatter); var formatters = resolver.GetAugmentedFormatters(newDateTimeFormatter, null, newByteArrayFormatter); Assert.AreEqual(3, formatters.Length); Assert.IsTrue(formatters.Contains(newDateTimeFormatter)); Assert.IsTrue(formatters.Contains(originalDateTimeOffsetFormatter)); Assert.IsTrue(formatters.Contains(newByteArrayFormatter)); var originalFormatters = resolver.GetFormatters(); Assert.AreEqual(2, originalFormatters.Length); Assert.IsTrue(originalFormatters.Contains(originalDateTimeFormatter)); Assert.IsTrue(originalFormatters.Contains(originalDateTimeOffsetFormatter)); }