Beispiel #1
0
        public void CopyToTest2()
        {
            var bag = new HashBag <int> {
                3, 5, 1, 4, 6, 2
            };

            Assert.Throws <ArgumentNullException>(() => bag.CopyTo(null, 0));
        }
Beispiel #2
0
        public void CopyToTest6()
        {
            var bag = new HashBag <int> {
                3, 5, 1, 4, 6, 2
            };
            var array = new int[6];

            Assert.Throws <ArgumentException>(() => bag.CopyTo(array, 18));
        }
Beispiel #3
0
        public void CopyToTest1()
        {
            var bag = new HashBag <int> {
                3, 5, 1, 4, 6, 2
            };
            var array = new int[6];

            bag.CopyTo(array, 0);

            Assert.Equal(new[] { 3, 5, 1, 4, 6, 2 }, array);
        }
Beispiel #4
0
        public void CopyTo()
        {
            //Note: for small ints the itemequalityComparer is the identity!
            hashbag.CopyTo(a, 1);
            Assert.AreEqual("Alles klar", aeq(a, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009));
            hashbag.Add(6);
            hashbag.CopyTo(a, 2);
            Assert.AreEqual("Alles klar", aeq(a, 1000, 1001, 6, 1003, 1004, 1005, 1006, 1007, 1008, 1009));
            hashbag.Add(4);
            hashbag.Add(6);
            hashbag.Add(9);
            hashbag.CopyTo(a, 4);

            //TODO: make independent of interequalityComparer
            Assert.AreEqual("Alles klar", aeq(a, 1000, 1001, 6, 1003, 6, 6, 9, 4, 1008, 1009));
            hashbag.Clear();
            hashbag.Add(7);
            hashbag.CopyTo(a, 9);
            Assert.AreEqual("Alles klar", aeq(a, 1000, 1001, 6, 1003, 6, 6, 9, 4, 1008, 7));
        }