Ejemplo n.º 1
0
        public void TestEnumeratorDataReader()
        {
            var dic =
                new Dictionary <int, string>
            {
                { 1, "one" },
                { 2, "two" },
                { 3, "three" },
            };

            using (var dataReader = new EnumeratorDataReader <KeyValuePair <int, string> >(dic.GetEnumerator()))
            {
                Assert.True(dataReader.Read());
                Assert.Equal(1, dataReader.GetValue(0));
                Assert.Equal("one", dataReader.GetValue(1));
                Assert.True(dataReader.Read());
                Assert.Equal(2, dataReader.GetValue(0));
                Assert.Equal("two", dataReader.GetValue(1));
                Assert.True(dataReader.Read());
                Assert.Equal(3, dataReader.GetValue(0));
                Assert.Equal("three", dataReader.GetValue(1));
                Assert.False(dataReader.Read());
                Assert.False(dataReader.Read());
            }
        }
Ejemplo n.º 2
0
        public void TestEnumeratorDataReader()
        {
            var dic =
                new Dictionary <int, string>
            {
                { 1, "one" },
                { 2, "two" },
                { 3, "three" },
            };

            using (var dataReader = new EnumeratorDataReader <KeyValuePair <int, string> >(dic.GetEnumerator()))
            {
                Assert.IsTrue(dataReader.Read());
                Assert.That(dataReader.GetValue(0), Is.EqualTo(1));
                Assert.That(dataReader.GetValue(1), Is.EqualTo("one"));
                Assert.IsTrue(dataReader.Read());
                Assert.That(dataReader.GetValue(0), Is.EqualTo(2));
                Assert.That(dataReader.GetValue(1), Is.EqualTo("two"));
                Assert.IsTrue(dataReader.Read());
                Assert.That(dataReader.GetValue(0), Is.EqualTo(3));
                Assert.That(dataReader.GetValue(1), Is.EqualTo("three"));
                Assert.IsFalse(dataReader.Read());
                Assert.IsFalse(dataReader.Read());
            }
        }
Ejemplo n.º 3
0
 public void TestEnumeratorDataReader()
 {
     var dic =
         new Dictionary<int, string>
             {
                 {1, "one"},
                 {2, "two"},
                 {3, "three"},
             };
     using (var dataReader = new EnumeratorDataReader<KeyValuePair<int, string>>(dic.GetEnumerator()))
     {
         Assert.IsTrue(dataReader.Read());
         Assert.That(dataReader.GetValue(0), Is.EqualTo(1));
         Assert.That(dataReader.GetValue(1), Is.EqualTo("one"));
         Assert.IsTrue(dataReader.Read());
         Assert.That(dataReader.GetValue(0), Is.EqualTo(2));
         Assert.That(dataReader.GetValue(1), Is.EqualTo("two"));
         Assert.IsTrue(dataReader.Read());
         Assert.That(dataReader.GetValue(0), Is.EqualTo(3));
         Assert.That(dataReader.GetValue(1), Is.EqualTo("three"));
         Assert.IsFalse(dataReader.Read());
         Assert.IsFalse(dataReader.Read());
     }
 }