Ejemplo n.º 1
0
 public void Returns_key_and_value_sizes_for_dictionaries()
 {
     Assert.AreEqual(16, FieldDataUtil.EstimateSize(new Dictionary <string, object>
     {
         ["ābc"]  = "def",
         ["hijk"] = "lmnö"
     }));
 }
Ejemplo n.º 2
0
 public void Handles_lists_in_dictionaries()
 {
     Assert.AreEqual(18, FieldDataUtil.EstimateSize(new Dictionary <string, object>
     {
         ["ābc"] = new Dictionary <string, object>
         {
             ["b"] = new [] { "aa", "bb" }
         },
         ["hijk"] = "lmnö"
     }));
 }
Ejemplo n.º 3
0
            public void Dictionaries_does_not_remove_empty_values()
            {
                var input = new Dictionary <string, object>
                {
                    ["key1"] = "ffff ffff",
                    ["key2"] = "abcd def"
                };

                var result = FieldDataUtil.Truncate(input, 6) as Dictionary <string, object>;

                Assert.AreEqual("", result["key1"]);
                Assert.AreEqual("abcd def", result["key2"]);
            }
Ejemplo n.º 4
0
            public void Arrays_remove_entire_values()
            {
                var input = new[]
                {
                    "ffff ffff",
                    "abcd def"
                };

                CollectionAssert.AreEqual(
                    new[] { "ffff" },
                    FieldDataUtil.Truncate(input, 12) as ICollection
                    );
            }
Ejemplo n.º 5
0
            public void Arrays_trim_values_from_end()
            {
                var input = new []
                {
                    "ffff ffff",
                    "abcd def"
                };

                CollectionAssert.AreEqual(
                    new[] { "ffff ffff", "abcd" },
                    FieldDataUtil.Truncate(input, 3) as ICollection
                    );
            }
Ejemplo n.º 6
0
 public void Strings_return_blank_when_word_barrier_is_first()
 {
     Assert.AreEqual("", FieldDataUtil.Truncate("abcd def", 5));
 }
Ejemplo n.º 7
0
 public void Strings_return_blank_when_truncating_more_than_string_size()
 {
     Assert.AreEqual("", FieldDataUtil.Truncate("abcd def", 20));
 }
Ejemplo n.º 8
0
 public void Strings_truncate_to_word_barrier()
 {
     Assert.AreEqual("abcd", FieldDataUtil.Truncate("abcd def", 2));
 }
Ejemplo n.º 9
0
 public void Strings_remove_specified_bytes_as_characters()
 {
     Assert.AreEqual("abcd", FieldDataUtil.Truncate("abcd def", 3));
 }
Ejemplo n.º 10
0
 public void Handles_lists_with_nested_lists()
 {
     Assert.AreEqual(11, FieldDataUtil.EstimateSize(new object[] { "a", new[] { "ābcdef", "ghi" } }));
 }
Ejemplo n.º 11
0
 public void Returns_total_element_size_for_lists()
 {
     Assert.AreEqual(10, FieldDataUtil.EstimateSize(new[] { "ābcdef", "ghi" }));
 }
Ejemplo n.º 12
0
 public void Returns_UTF8_byte_count_for_strings()
 {
     Assert.AreEqual(7, FieldDataUtil.EstimateSize("ābcdef"));
 }