public void GetAugmentedFormatters_Returns_Formatters()
        {
            var formatter = new DateTime_JavaScriptTicks_Formatter();
            var resolver  = new TypeFormatterResolver(formatter);

            var formatters = resolver.GetAugmentedFormatters(null);

            Assert.AreEqual(1, formatters.Length);
            Assert.AreSame(formatter, formatters[0]);
        }
Beispiel #2
0
        public void Format_Behaves_Correctly(string rawValue, string expected)
        {
            using (new CultureSwap("en-GB")) {
                var value     = DataRowParser.DateTime(rawValue).Value;
                var formatter = new DateTime_JavaScriptTicks_Formatter();

                var actual = formatter.Format(value);

                Assert.AreEqual(expected, actual);
            }
        }
        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));
        }