Beispiel #1
0
        public void AddChild()
        {
            // Null child.
            {
                var o = new ValueMap();

                o.AddChild(null);

                Assert.AreEqual(0, o.ChildMaps.Count);
            }

            // Valid child.
            {
                var o     = new ValueMap();
                var child = new ValueMap();
                o.AddChild(child);

                Assert.AreEqual(1, o.ChildMaps.Count);
                Assert.AreEqual(child, o.ChildMaps[0]);
            }
        }
Beispiel #2
0
        public void Clear()
        {
            // No items.
            {
                var o = new ValueMap();

                Assert.AreEqual(0, o.Values.Count);
                Assert.AreEqual(0, o.ChildMaps.Count);

                o.Clear();

                Assert.AreEqual(0, o.Values.Count);
                Assert.AreEqual(0, o.ChildMaps.Count);
            }

            // Only values.
            {
                var o = new ValueMap();
                o.AddParam(RequestParam.AccountID, true);
                o.AddParam(RequestParam.AccountName, "Test");

                Assert.AreEqual(2, o.Values.Count);
                Assert.AreEqual(0, o.ChildMaps.Count);

                o.Clear();

                Assert.AreEqual(0, o.Values.Count);
                Assert.AreEqual(0, o.ChildMaps.Count);
            }

            // Values and child maps.
            {
                var o = new ValueMap();

                o.AddParam(RequestParam.AccountID, true);
                o.AddParam(RequestParam.AccountName, "Test");
                o.AddChild(new ValueMap());

                Assert.AreEqual(2, o.Values.Count);
                Assert.AreEqual(1, o.ChildMaps.Count);

                o.Clear();

                Assert.AreEqual(0, o.Values.Count);
                Assert.AreEqual(0, o.ChildMaps.Count);
            }

            // Only child maps.
            {
                var o = new ValueMap();

                o.AddChild(new ValueMap());

                Assert.AreEqual(0, o.Values.Count);
                Assert.AreEqual(1, o.ChildMaps.Count);

                o.Clear();

                Assert.AreEqual(0, o.Values.Count);
                Assert.AreEqual(0, o.ChildMaps.Count);
            }
        }