Пример #1
0
        public void TestRead()
        {
            using (IDataReader reader = new InMemoryDataReader(false, this.Data1))
            {
                Assert.IsTrue(reader.Read(), "Read 1");
                Assert.AreEqual("R1C2", reader.GetString(1));

                Assert.IsTrue(reader.Read(), "Read 2");
                Assert.AreEqual("R2C1", reader.GetString(0));

                Assert.IsTrue(reader.Read(), "Read 3");
                Assert.AreEqual("R3C3", reader.GetString(2));

                Assert.IsFalse(reader.Read(), "Read 4");
            }
        }
Пример #2
0
 public void TestGetStringNull()
 {
     using (IDataReader reader = new InMemoryDataReader(false, this.Data4))
     {
         reader.Read();
         Assert.Throws <InvalidOperationException>(() => reader.GetString(1));
     }
 }
Пример #3
0
 public void TestGetBoolean()
 {
     using (IDataReader reader = new InMemoryDataReader(false, this.Data3))
     {
         Assert.IsTrue(reader.Read(), "Read");
         Assert.IsTrue(reader.GetBoolean(0));
         Assert.IsFalse(reader.GetBoolean(1));
     }
 }
Пример #4
0
 public void TestNextResult()
 {
     using (IDataReader reader = new InMemoryDataReader(false, this.Data1, this.Data2))
     {
         Assert.AreEqual(3, reader.FieldCount, "Field count.");
         Assert.IsTrue(reader.NextResult(), "Next result");
         Assert.AreEqual(2, reader.FieldCount, "Field count has changed.");
         Assert.IsTrue(reader.Read(), "Read");
         Assert.AreEqual("TWO R1C2", reader.GetString(1), "Row 1 column 2.");
     }
 }
Пример #5
0
        public void TestGetValuesWithNull()
        {
            using (IDataReader reader = new InMemoryDataReader(false, this.Data4))
            {
                Assert.IsTrue(reader.Read(), "Read");

                object[] buffer = new object[3];
                Assert.AreEqual(2, reader.GetValues(buffer), "Number of values");
                var strings = buffer.Cast <string>().ToArray();
                Assert.AreEqual(new string[] { "R1C1", null, "R1C3" }, strings, "Data equal");
            }
        }