예제 #1
0
        public void MergeWith_StringReplacesExistingKey()
        {
            var dict1 = new BDictionary {
                { "key", "value" }
            };
            var dict2 = new BDictionary {
                { "key", "replaced value" }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().Be((BString)"replaced value");
        }
예제 #2
0
        public void MergeWith_NumberReplacesExistingKey()
        {
            var dict1 = new BDictionary {
                { "key", 1 }
            };
            var dict2 = new BDictionary {
                { "key", 42 }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().Be((BNumber)42);
        }
예제 #3
0
        public void MergeWith_StringWithNewKeyIsAdded()
        {
            var dict1 = new BDictionary {
                { "key", "value" }
            };
            var dict2 = new BDictionary {
                { "another key", "value" }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1["key"].Should().Be((BString)"value");
            dict1["another key"].Should().Be((BString)"value");
        }
예제 #4
0
        public void MergeWith_NumberWithNewKeyIsAdded()
        {
            var dict1 = new BDictionary {
                { "key", 1 }
            };
            var dict2 = new BDictionary {
                { "another key", 42 }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1["key"].Should().Be((BNumber)1);
            dict1["another key"].Should().Be((BNumber)42);
        }
예제 #5
0
        public void MergeWith_ListWithNewKeyIsAdded()
        {
            var list = new BList {
                1, 2, 3
            };
            var dict1 = new BDictionary {
                { "key", 1 }
            };
            var dict2 = new BDictionary {
                { "another key", list }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1["key"].Should().Be((BNumber)1);
            dict1["another key"].Should().Be(list);
        }
예제 #6
0
        public void MergeWith_ExistingKeyOption_Merge_DictionaryMergedWithExistingKeyOfSameType()
        {
            var dict1 = new BDictionary {
                { "main", new BDictionary {
                      { "key", "value" }
                  } }
            };
            var dict2 = new BDictionary {
                { "main", new BDictionary {
                      { "key2", "value2" }
                  } }
            };

            dict1.MergeWith(dict2, ExistingKeyAction.Merge);

            dict1.Should().HaveCount(1);
            dict1.Get <BDictionary>("main").Should().HaveCount(2).And.ContainKeys("key", "key2");
        }
예제 #7
0
        public void MergeWith_ExistingKeyOption_Skip_DictionarySkippedForExistingKeyOfSameType()
        {
            var dict1 = new BDictionary {
                { "main", new BDictionary {
                      { "key", "value" }
                  } }
            };
            var dict2 = new BDictionary {
                { "main", new BDictionary {
                      { "key2", "value2" }
                  } }
            };

            dict1.MergeWith(dict2, ExistingKeyAction.Skip);

            dict1.Should().HaveCount(1);
            dict1.Get <BDictionary>("main").Should().HaveCount(1).And.ContainKey("key");
        }
예제 #8
0
        public void MergeWith_DictionaryReplacesExistingKeyOfDifferentType()
        {
            var dict1 = new BDictionary {
                { "main", new BList {
                      "item1"
                  } }
            };
            var dict2 = new BDictionary {
                { "main", new BDictionary {
                      { "key", "value" }
                  } }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1.Get <BDictionary>("main").Should().HaveCount(1).And.ContainKey("key");
        }
예제 #9
0
        public void MergeWith_DictionaryWithNewKeyIsAdded()
        {
            var dict1 = new BDictionary {
                { "main", new BDictionary {
                      { "key", "value" }
                  } }
            };
            var dict2 = new BDictionary {
                { "main2", new BDictionary {
                      { "key2", "value2" }
                  } }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1.Get <BDictionary>("main").Should().HaveCount(1).And.ContainKeys("key");
            dict1.Get <BDictionary>("main2").Should().HaveCount(1).And.ContainKeys("key2");
        }
예제 #10
0
        public void MergeWith_ListReplacesExistingKeyOfDifferentType()
        {
            var dict1 = new BDictionary {
                { "key", "value" }
            };
            var dict2 = new BDictionary {
                { "key", new BList {
                      "item1", "item2"
                  } }
            };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().BeOfType <BList>();
            dict1.Get <BList>("key").Should()
            .HaveCount(2)
            .And.ContainInOrder((BString)"item1", (BString)"item2");
        }
예제 #11
0
        public void MergeWith_ExistingKeyOption_Skip_ListIsSkippedForExistingKeyOfSameType()
        {
            var dict1 = new BDictionary {
                { "key", new BList {
                      "item1"
                  } }
            };
            var dict2 = new BDictionary {
                { "key", new BList {
                      "item2", "item3"
                  } }
            };

            dict1.MergeWith(dict2, ExistingKeyAction.Skip);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().BeOfType <BList>();
            dict1.Get <BList>("key").Should()
            .HaveCount(1)
            .And.ContainInOrder((BString)"item1");
        }
예제 #12
0
        public void MergeWith_ExistingKeyOption_Merge_DictionaryMergedWithExistingKeyOfSameType()
        {
            var dict1 = new BDictionary {{"main", new BDictionary {{"key", "value"}}}};
            var dict2 = new BDictionary {{"main", new BDictionary {{"key2", "value2"}}}};

            dict1.MergeWith(dict2, ExistingKeyAction.Merge);

            dict1.Should().HaveCount(1);
            dict1.Get<BDictionary>("main").Should().HaveCount(2).And.ContainKeys("key", "key2");
        }
예제 #13
0
        public void MergeWith_DictionaryReplacesExistingKeyOfDifferentType()
        {
            var dict1 = new BDictionary {{"main", new BList {"item1"}}};
            var dict2 = new BDictionary {{"main", new BDictionary {{"key", "value"}}}};

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1.Get<BDictionary>("main").Should().HaveCount(1).And.ContainKey("key");
        }
예제 #14
0
        public void MergeWith_ExistingKeyOption_Skip_ListIsSkippedForExistingKeyOfSameType()
        {
            var dict1 = new BDictionary {{"key", new BList {"item1"}}};
            var dict2 = new BDictionary {{"key", new BList {"item2", "item3"}}};

            dict1.MergeWith(dict2, ExistingKeyAction.Skip);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().BeOfType<BList>();
            dict1.Get<BList>("key").Should()
                .HaveCount(1)
                .And.ContainInOrder((BString) "item1");
        }
예제 #15
0
        public void MergeWith_ExistingKeyOption_Skip_DictionarySkippedForExistingKeyOfSameType()
        {
            var dict1 = new BDictionary {{"main", new BDictionary {{"key", "value"}}}};
            var dict2 = new BDictionary {{"main", new BDictionary {{"key2", "value2"}}}};

            dict1.MergeWith(dict2, ExistingKeyAction.Skip);

            dict1.Should().HaveCount(1);
            dict1.Get<BDictionary>("main").Should().HaveCount(1).And.ContainKey("key");
        }
예제 #16
0
        public void MergeWith_ListWithNewKeyIsAdded()
        {
            var list = new BList {1, 2, 3};
            var dict1 = new BDictionary {{"key", 1}};
            var dict2 = new BDictionary {{"another key", list}};

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1["key"].Should().Be((BNumber) 1);
            dict1["another key"].Should().Be(list);
        }
예제 #17
0
        public void MergeWith_ListReplacesExistingKeyOfDifferentType()
        {
            var dict1 = new BDictionary {{"key", "value"}};
            var dict2 = new BDictionary {{"key", new BList {"item1", "item2"}}};

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().BeOfType<BList>();
            dict1.Get<BList>("key").Should()
                .HaveCount(2)
                .And.ContainInOrder((BString) "item1", (BString) "item2");
        }
예제 #18
0
        public void MergeWith_NumberReplacesExistingKey()
        {
            var dict1 = new BDictionary {{"key", 1}};
            var dict2 = new BDictionary {{"key", 42}};

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().Be((BNumber) 42);
        }
예제 #19
0
        public void MergeWith_NumberWithNewKeyIsAdded()
        {
            var dict1 = new BDictionary {{"key", 1}};
            var dict2 = new BDictionary {{"another key", 42}};

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1["key"].Should().Be((BNumber) 1);
            dict1["another key"].Should().Be((BNumber) 42);
        }
예제 #20
0
        public void MergeWith_StringReplacesExistingKey()
        {
            var dict1 = new BDictionary {{"key", "value"}};
            var dict2 = new BDictionary {{"key", "replaced value"}};

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(1);
            dict1["key"].Should().Be((BString)"replaced value");
        }
예제 #21
0
        public void MergeWith_StringWithNewKeyIsAdded()
        {
            var dict1 = new BDictionary {{"key", "value"}};
            var dict2 = new BDictionary {{"another key", "value"}};

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1["key"].Should().Be((BString)"value");
            dict1["another key"].Should().Be((BString)"value");
        }
예제 #22
0
        public void MergeWith_DictionaryWithNewKeyIsAdded()
        {
            var dict1 = new BDictionary { { "main", new BDictionary { { "key", "value" } } } };
            var dict2 = new BDictionary { { "main2", new BDictionary { { "key2", "value2" } } } };

            dict1.MergeWith(dict2);

            dict1.Should().HaveCount(2);
            dict1.Get<BDictionary>("main").Should().HaveCount(1).And.ContainKeys("key");
            dict1.Get<BDictionary>("main2").Should().HaveCount(1).And.ContainKeys("key2");
        }