Esempio n. 1
0
        public void Move()
        {
            NamedObjectCollection <NamedTestObject> collection = new NamedObjectCollection <NamedTestObject>();

            collection.Add(new NamedTestObject("foo1", 1));
            collection.Add(new NamedTestObject("foo2", 2));
            collection.Add(new DerivedNamedTestObject("foo3", 3));

            Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(-1, 1));
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(1, -1));
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(3, 1));
            Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(1, 3));

            collection.Move(1, 1);
            Assert.AreEqual(2, collection[1].Value);

            collection.Move(0, 2);
            Assert.AreEqual(2, collection[0].Value);
            Assert.AreEqual(3, collection[1].Value);
            Assert.AreEqual(1, collection[2].Value);
        }
        public void Move()
        {
            NamedObjectCollection<NamedTestObject> collection = new NamedObjectCollection<NamedTestObject>();
              collection.Add(new NamedTestObject("foo1", 1));
              collection.Add(new NamedTestObject("foo2", 2));
              collection.Add(new DerivedNamedTestObject("foo3", 3));

              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(-1, 1));
              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(1, -1));
              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(3, 1));
              Assert.Throws(typeof(ArgumentOutOfRangeException), () => collection.Move(1, 3));

              collection.Move(1, 1);
              Assert.AreEqual(2, collection[1].Value);

              collection.Move(0, 2);
              Assert.AreEqual(2, collection[0].Value);
              Assert.AreEqual(3, collection[1].Value);
              Assert.AreEqual(1, collection[2].Value);
        }