Пример #1
0
        public void Constructor()
        {
            var source = new CloneableType[4, 2]
            {
                { "a", "b" }, { "c", "d" }, { "e", "f" }, { "g", "h" }
            };
            StringArray array = new StringArray(source, true);

            Assert.AreEqual(8, array.Length);
            Assert.AreEqual(2, array.Rank);
            Assert.AreEqual(4, array.GetLength(0));
            Assert.AreEqual(2, array.GetLength(1));

            // check equality by multidimensional index
            for (int i = 0; i < array.Length; i++)
            {
                int[] indices = array.GetIndices(i);
                var   value   = source.GetValue(indices);
                Assert.AreEqual(value, array[i]);
                Assert.AreSame(value, array[i]);
            }

            // check equality by enumeration sequence
            int index = 0;

            foreach (CloneableType value in source)
            {
                Assert.AreEqual(value, array[index]);
                Assert.AreSame(value, array[index]);
                index++;
            }
        }
Пример #2
0
        public void ToArrayWithShape()
        {
            var array = (CloneableType[, ])_array.ToArrayWithShape();

            Assert.AreEqual(_array.Length, array.Length);
            Assert.AreEqual(_array.Rank, array.Rank);
            Assert.AreEqual(_array.GetLength(0), array.GetLength(0));
            Assert.AreEqual(_array.GetLength(1), array.GetLength(1));

            CompareToArray(array, true);
        }
Пример #3
0
        public void SetUp()
        {
            _array    = new StringArray(2, 3);
            _readOnly = _array.AsReadOnly();

            Assert.AreEqual(6, _array.Length);
            Assert.AreEqual(2, _array.Rank);
            Assert.AreEqual(2, _array.GetLength(0));
            Assert.AreEqual(3, _array.GetLength(1));

            _array[0, 0] = "one"; _array[0, 1] = "two"; _array[0, 2] = "three";
            _array[1, 0] = "four"; _array[1, 1] = "five"; _array[1, 2] = "six";
        }