Ejemplo n.º 1
0
        public void Trees_only_compare_using_referenceEquals()
        {
            var tree1 = Sigo.Create(3).Set1("k", Sigo.From("v"));
            var tree2 = Sigo.Create(3).Set1("k", Sigo.From("v"));

            SigoAssert.True(Sigo.Same(tree1, tree1));

            SigoAssert.False(Sigo.Same(tree1, tree2));
        }
Ejemplo n.º 2
0
        public void Leafs_compare_data_using_equals()
        {
            var v1 = Sigo.From("v");
            var v2 = Sigo.From("v");
            var x1 = Sigo.From("x");

            SigoAssert.True(Sigo.Same(v1, v1));
            SigoAssert.True(Sigo.Same(v1, v2));

            SigoAssert.False(Sigo.Same(v1, x1));
        }
Ejemplo n.º 3
0
        public void NonEmptyTree_areNotFrozen_after_creating_or_changing()
        {
            // non empty tree are not frozen after creating
            SigoAssert.False(tree.IsFrozen());

            // not frozen after changing
            tree = tree.Freeze().Set1("v", Sigo.From("v+"));
            SigoAssert.False(tree.IsFrozen());

            // leafs and elements are frozen always frozen
            SigoAssert.True(leaf.IsFrozen());
            SigoAssert.True(e3.IsFrozen());
        }
Ejemplo n.º 4
0
        public void Return_leaf_if_input_is_scalar()
        {
            var inputs = new object[] {
                true, false,
                123.0,
                "",
                "abc"
            };

            foreach (var scalar in inputs)
            {
                var sigo = Sigo.From(scalar);

                SigoAssert.True(sigo.IsLeaf());
                SigoAssert.Equal(scalar, sigo.Data);
            }
        }
Ejemplo n.º 5
0
        public void Convert_to_tree_if_input_is_enumerable()
        {
            var inputs = new object[] {
                new[] { "a", "b" },
                new List <string> {
                    "a", "b"
                }
            };

            foreach (var o in inputs)
            {
                var sigo = Sigo.From(o);

                SigoAssert.True(sigo.IsTree());
                SigoAssert.Equal("a", sigo.Get1("0").Data);
                SigoAssert.Equal("b", sigo.Get1("1").Data);
            }
        }
Ejemplo n.º 6
0
        public void NonFrozen_return_new_obj()
        {
            var user = Sigo.Create(3,
                                   "name", Sigo.Create(3,
                                                       "first", "Phat",
                                                       "last", "Dam"),
                                   "frozen", Sigo.Create(0, "k", "v").Freeze()
                                   );

            SigoAssert.False(user.IsFrozen());
            SigoAssert.False(user.Get("name").IsFrozen());
            SigoAssert.True(user.Get("frozen").IsFrozen());

            var clone = user.Clone();

            SigoAssert.NotSame(user, clone);
            SigoAssert.NotSame(user.Get("name"), clone.Get("name"));
            SigoAssert.Same(user.Get("frozen"), clone.Get("frozen"));
        }
Ejemplo n.º 7
0
        public void Convert_to_tree_if_input_is_dictionary()
        {
            var inputs = new object[] {
                new Hashtable()
                {
                    { "k", "v" }
                },
                new Dictionary <string, object>()
                {
                    { "k", "v" }
                }
            };

            foreach (var o in inputs)
            {
                var sigo = Sigo.From(o);

                SigoAssert.True(sigo.IsTree());
                SigoAssert.Equal("v", sigo.Get1("k").Data);
            }
        }
Ejemplo n.º 8
0
 public void Frozen_a_nonFrozen()
 {
     tree.Freeze();
     SigoAssert.True(tree.IsFrozen());
 }