Пример #1
0
        public void TestMultiValueTreeMapMin()
        {
            var mvMap = new MultiValueTreeMap <int, Bill>();

            Fill(mvMap, 1000, 20, x => x, valueGen);
            Assert.Equal(0, mvMap.Min);
        }
Пример #2
0
        public void TestMultiValueSortedMapExceptions()
        {
            var mvMap = new MultiValueTreeMap <int, Bill>();

            Assert.Throws(typeof(InvalidOperationException), () => mvMap.Max);
            Assert.Throws(typeof(InvalidOperationException), () => mvMap.Min);
            Assert.Throws(typeof(InvalidOperationException), () => mvMap.RemoveMin());
            Assert.Throws(typeof(InvalidOperationException), () => mvMap.RemoveMax());
        }
Пример #3
0
        public void TestMultiValueTreeMapEmpty()
        {
            var mvMap = new MultiValueTreeMap <int, Bill>();

            Assert.True(mvMap.IsEmpty);
            Fill(mvMap, 100, 10, x => x, (y, z) => new Bill {
                Id = z
            });
            Assert.False(mvMap.IsEmpty);
        }
Пример #4
0
        public void TestMultiValueTreeMapRemoveMin()
        {
            var mvMap = new MultiValueTreeMap <int, Bill>();

            Fill(mvMap, 1000, 20, x => x, valueGen);
            mvMap.RemoveMin();
            Assert.Equal(999, mvMap.KeyCount);
            Assert.Equal(999, mvMap.Keys.Count);
            Assert.Equal(1, mvMap.Min);
            Assert.Equal(999 * 20, mvMap.Count);
        }
Пример #5
0
        public void TestMultiValueTreeMapRemove()
        {
            var mvMap = new MultiValueTreeMap <int, Bill>(Comparer <int> .Default, new BillEqualityComparer());

            MultiValueMapRemove(mvMap);
        }
Пример #6
0
        public void TestMultiValueTreeMapAddSingleValueAndCollectionValue()
        {
            var mvMap = new MultiValueTreeMap <int, Bill>(Comparer <int> .Default, new BillEqualityComparer());

            MultiValueMapAddSingleValueAndCollectionValue(mvMap);
        }
Пример #7
0
        public void TestMultiValueTreeMapConstructor()
        {
            var mvMap1 = new MultiValueTreeMap <int, int>();

            MultiValueMapOperations(mvMap1);

            var mvMap2 = new MultiValueTreeMap <int, int>(Comparer <int> .Default.Compare);

            MultiValueMapOperations(mvMap2);

            var mvMap3 = new MultiValueTreeMap <int, int>(Comparer <int> .Default.Compare, EqualityComparer <int> .Default.Equals);

            MultiValueMapOperations(mvMap3);

            var mvMap4 = new MultiValueTreeMap <int, int>(Comparer <int> .Default, EqualityComparer <int> .Default);

            MultiValueMapOperations(mvMap4);

            var mvMap5 = new MultiValueTreeMap <int, int>(Comparer <int> .Default);

            MultiValueMapOperations(mvMap5);

            var mvMap0 = new MultiValueTreeMap <Order, Bill>(new OrderComparer(), new BillEqualityComparer());

            Fill(mvMap0, 1000, 20, x => new Order {
                Id = x
            }, (y, z) => new Bill {
                Id = z
            });
            var mvMap6 = new MultiValueTreeMap <Order, Bill>(mvMap0, new OrderComparer().Compare, new BillEqualityComparer().Equals);

            Assert.Equal(mvMap0.Count, mvMap6.Count);
            Assert.Equal(mvMap0.Keys.Count, mvMap6.Keys.Count);
            for (var i = 0; i < 1000; i++)
            {
                Assert.True(mvMap6.ContainsKey(new Order {
                    Id = i
                }));
                var bills = mvMap6[new Order {
                                       Id = i
                                   }];
                for (var j = 0; j < 20; j++)
                {
                    Assert.True(bills.Contains(new Bill {
                        Id = j
                    }, new BillEqualityComparer()));
                }
            }
            mvMap6.Clear();
            Assert.Equal(0, mvMap6.Count);
            Fill(mvMap6, 200, 5, x => new Order {
                Id = x
            }, (y, z) => new Bill {
                Id = z
            });
            for (var i = 0; i < 200; i++)
            {
                Assert.True(mvMap6.ContainsKey(new Order {
                    Id = i
                }));
                var bills = mvMap6[new Order {
                                       Id = i
                                   }];
                for (var j = 0; j < 5; j++)
                {
                    Assert.True(bills.Contains(new Bill {
                        Id = j
                    }, new BillEqualityComparer()));
                }
            }

            var mvMap = new MultiValueTreeMap <int, int>();

            Fill(mvMap, 1000, 20, x => x, (y, z) => z);
            var mvMap7 = new MultiValueTreeMap <int, int>(mvMap);

            Assert.Equal(1000, mvMap7.Keys.Count);
            Assert.Equal(1000, mvMap7.KeyCount);
            Assert.Equal(mvMap.KeyCount, mvMap7.KeyCount);

            for (var i = 0; i < 1000; i++)
            {
                Assert.True(mvMap7.ContainsKey(i));
                var values = mvMap7[i];
                for (var j = 0; j < 20; j++)
                {
                    Assert.True(values.Contains(j));
                }
            }
        }