Exemplo n.º 1
0
        /// <summary>
        /// Asserts that we get the right output even after reversing the order of input.
        /// </summary>
        private void AssertExpandObjectValid(OrderPreservingDictionary <FieldPath, Value> input, Dictionary <string, Value> expected)
        {
            var actual = WriteBatch.ExpandObject(input);

            Assert.Equal(expected, actual);
            actual = WriteBatch.ExpandObject(input.InReverseOrder());
            Assert.Equal(expected, actual);
        }
Exemplo n.º 2
0
            public OrderPreservingDictionary <TKey, TValue> InReverseOrder()
            {
                var ret = new OrderPreservingDictionary <TKey, TValue>();

                foreach (var item in this.Reverse())
                {
                    ret.Add(item);
                }
                return(ret);
            }
        public void RemoveFirstEmptyList()
        {
            OrderPreservingDictionary <object, int> dictEmpty = new OrderPreservingDictionary <object, int>();

            dictEmpty.RemoveFirst();
            var keyList = dictEmpty.GetKeys();

            CollectionAssert.AreEqual(new List <object> {
            }, keyList);
        }
Exemplo n.º 4
0
        public void ExpandObject_IntermediateMapMerging()
        {
            var input = new OrderPreservingDictionary <FieldPath, Value>
            {
                { new FieldPath("a", "b", "c"), CreateValue(10) },
                { new FieldPath("a", "b", "d"), CreateValue(20) }
            };
            var expected = new Dictionary <string, Value>
            {
                { "a", CreateMap("b", CreateMap(("c", CreateValue(10)), ("d", CreateValue(20)))) }
            };

            AssertExpandObjectValid(input, expected);
        }
Exemplo n.º 5
0
        public void ExpandObject_DottedFieldPath()
        {
            var input = new OrderPreservingDictionary <FieldPath, Value>
            {
                // These two field paths are unrelated
                { new FieldPath("a.b"), CreateValue(10) },
                { new FieldPath("a", "b"), CreateValue(20) },
            };
            var expected = new Dictionary <string, Value>
            {
                { "a.b", CreateValue(10) },
                { "a", CreateMap("b", CreateValue(20)) },
            };

            AssertExpandObjectValid(input, expected);
        }
Exemplo n.º 6
0
        public void ExpandObject_DisjointKeys()
        {
            var input = new OrderPreservingDictionary <FieldPath, Value>
            {
                { new FieldPath("a"), CreateValue(10) },
                { new FieldPath("b"), CreateValue(20) },
                { new FieldPath("c", "d"), CreateValue(30) }
            };
            var expected = new Dictionary <string, Value>
            {
                { "a", CreateValue(10) },
                { "b", CreateValue(20) },
                { "c", CreateMap("d", CreateValue(30)) }
            };

            AssertExpandObjectValid(input, expected);
        }
Exemplo n.º 7
0
 /// <summary>
 /// Asserts that expanding the given input fails in both the original order and reverse order.
 /// </summary>
 private void AssertExpandObjectInvalid(OrderPreservingDictionary <FieldPath, Value> input)
 {
     Assert.Throws <InvalidOperationException>(() => WriteBatch.ExpandObject(input));
     Assert.Throws <InvalidOperationException>(() => WriteBatch.ExpandObject(input.InReverseOrder()));
 }