コード例 #1
0
        public void Write__EmptyString__ReturnsStringRepresentingEmptyString()
        {
            var ow = new StringObjectWriter();

            var r = ow.Write("");

            Assert.AreEqual("[EMPTY]", r);

            r = ow.Write("", emptyValue: "123");

            Assert.AreEqual("123", r);
        }
コード例 #2
0
        public void Write__KeyValuePairCollection__KeysAreAligned()
        {
            var ow = new StringObjectWriter();

            var kvpc = new KeyValuePairCollection();

            kvpc.Add(new KeyValuePair("1", " "));
            kvpc.Add(new KeyValuePair("12", " "));
            kvpc.Add(new KeyValuePair("1234", " "));
            kvpc.Add(new KeyValuePair("12345", " "));
            kvpc.Add(new KeyValuePair("1234567890", " "));
            kvpc.Add(new KeyValuePair("123456789012345678901", " "));

            var r = ow.Write(kvpc);

            var expected =
                 "1\t\t\t\t\t\t:\t "
                + Environment.NewLine
                + "12\t\t\t\t\t\t:\t "
                + Environment.NewLine
                +"1234\t\t\t\t\t:\t "
                + Environment.NewLine
                + "12345\t\t\t\t\t:\t "
                + Environment.NewLine
                + "1234567890\t\t\t\t:\t "
                + Environment.NewLine
                + "123456789012345678901\t:\t ";

            Assert.AreEqual(expected, r);
        }
コード例 #3
0
        public void Write__DateTime__ISO8601_WithoutTimeZone_WithoutT()
        {
            var ow = new StringObjectWriter();

            var r = ow.Write(DateTime.Parse("2013-12-30T23:24:25.1234567Z"));

            Assert.AreEqual("2013-12-30 23:24:25.1234567", r);
        }
コード例 #4
0
        public void Write__KeyValuePairCollection__MultiLineValuesAreHandled()
        {
            var ow = new StringObjectWriter();

            var kvpc = new KeyValuePairCollection();

            kvpc.Add(new KeyValuePair("key", "_line1_" + Environment.NewLine + "_line2_"));
            kvpc.Add(new KeyValuePair("key_0123456", " "));

            var r = ow.Write(kvpc);

            var expected =
                 "key\t\t\t:"
                + Environment.NewLine
                + "-------------"
                + Environment.NewLine
                + "\t_line1_"
                + Environment.NewLine
                + "\t_line2_"
                + Environment.NewLine
                + "key_0123456\t:\t ";

            Assert.AreEqual(expected, r);
        }
コード例 #5
0
        public void Write__Null__ReturnsStringRepresentingNullValue()
        {
            var ow = new StringObjectWriter();

            var r = ow.Write(null);

            Assert.AreEqual("[NULL]", r);

            r = ow.Write(null, "123");

            Assert.AreEqual("123", r);
        }
コード例 #6
0
        public void Write__KeyValuePair_ValueMultiLineString()
        {
            var ow = new StringObjectWriter();

            var kvp = new KeyValuePair("_key_", "_line1_" + Environment.NewLine + "_line2_");

            var r = ow.Write(kvp);

            var expected =
                  "_key_\t:"
                + Environment.NewLine
                + "---------"
                + Environment.NewLine
                + "\t_line1_"
                + Environment.NewLine
                + "\t_line2_";

            Assert.AreEqual(expected, r);
        }
コード例 #7
0
        public void Write__KeyValuePair_ValueIsSingleLineString()
        {
            var ow = new StringObjectWriter();

            var kvp = new KeyValuePair("_key_", "_value_");

            var r = ow.Write(kvp);

            Assert.AreEqual("_key_\t:\t_value_", r);
        }
コード例 #8
0
        public void Write__KeyValuePairCollection__ValueIsKeyValuePairCollection()
        {
            var ow = new StringObjectWriter();

            var kvpc = new KeyValuePairCollection();

            var value = new KeyValuePairCollection();

            value.Add(new KeyValuePair("key_1", "value_1"));
            value.Add(new KeyValuePair("key_2", "value_2"));

            kvpc.Add("item", value);

            var r = ow.Write(kvpc);

            var expected =
                 "item\t:"
                + Environment.NewLine
                + "---------"
                + Environment.NewLine
                + "\tkey_1\t:\tvalue_1"
                + Environment.NewLine
                + "\tkey_2\t:\tvalue_2";

            Assert.AreEqual(expected, r);
        }