Ejemplo n.º 1
0
        public void GetEnumeratorIteratesElementsInCorrectOrder()
        {
            using (NativeArray2D <int> array = CreateArray(2, 3))
            {
                NativeArray2D <int> alias = array;
                alias[0, 0] = 100;
                alias[0, 1] = 200;
                alias[0, 2] = 300;
                alias[1, 0] = 400;
                alias[1, 1] = 500;
                alias[1, 2] = 600;

                using (NativeArray2D <int> .Enumerator e = array.GetEnumerator())
                {
                    Assert.That(e.MoveNext(), Is.True);
                    Assert.That(e.Current, Is.EqualTo(array[0, 0]));
                    Assert.That(e.MoveNext(), Is.True);
                    Assert.That(e.Current, Is.EqualTo(array[1, 0]));
                    Assert.That(e.MoveNext(), Is.True);
                    Assert.That(e.Current, Is.EqualTo(array[0, 1]));
                    Assert.That(e.MoveNext(), Is.True);
                    Assert.That(e.Current, Is.EqualTo(array[1, 1]));
                    Assert.That(e.MoveNext(), Is.True);
                    Assert.That(e.Current, Is.EqualTo(array[0, 2]));
                    Assert.That(e.MoveNext(), Is.True);
                    Assert.That(e.Current, Is.EqualTo(array[1, 2]));
                    Assert.That(e.MoveNext(), Is.False);
                }
            }
        }
Ejemplo n.º 2
0
        public void EnumeratorCurrentReturnsCurrentElementAsObject()
        {
            using (NativeArray2D <int> array = CreateArray(2, 3))
            {
                NativeArray2D <int> alias = array;
                alias[0, 0] = 123;
                NativeArray2D <int> .Enumerator e = array.GetEnumerator();
                e.MoveNext();

                Assert.That(((IEnumerator)e).Current, Is.EqualTo(123));
            }
        }
Ejemplo n.º 3
0
        public void EnumeratorResetReturnsToFirstElement()
        {
            using (NativeArray2D <int> array = CreateArray(2, 3))
            {
                NativeArray2D <int> alias = array;
                alias[0, 0] = 123;
                NativeArray2D <int> .Enumerator e = array.GetEnumerator();
                e.MoveNext();

                e.Reset();

                Assert.That(e.MoveNext(), Is.True);
                Assert.That(e.Current, Is.EqualTo(123));
            }
        }