document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. namespace UnitTests
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Data;
  6.  
  7.     public class MockDataReader : IDataReader
  8.     {
  9.         private List<List<object>> mockedValues;
  10.         private List<string> schema;
  11.         private int currentIndex = -1;
  12.  
  13.         public MockDataReader(List<List<object>> mockedValues, List<string> schema)
  14.         {
  15.             if (mockedValues == null)
  16.             {
  17.                 throw new ArgumentNullException("mockedValues");
  18.             }
  19.  
  20.             if (schema == null)
  21.             {
  22.                 throw new ArgumentNullException("schema");
  23.             }
  24.  
  25.             this.mockedValues = mockedValues;
  26.             this.schema = schema;
  27.         }
  28.  
  29.         public void Dispose()
  30.         {
  31.         }
  32.  
  33.         public string GetName(int i)
  34.         {
  35.             throw new NotImplementedException();
  36.         }
  37.  
  38.         public string GetDataTypeName(int i)
  39.         {
  40.             throw new NotImplementedException();
  41.         }
  42.  
  43.         public Type GetFieldType(int i)
  44.         {
  45.             throw new NotImplementedException();
  46.         }
  47.  
  48.         public object GetValue(int i)
  49.         {
  50.             throw new NotImplementedException();
  51.         }
  52.  
  53.         public int GetValues(object[] values)
  54.         {
  55.             throw new NotImplementedException();
  56.         }
  57.  
  58.         public int GetOrdinal(string name)
  59.         {
  60.             for (int i = 0; i < schema.Count; i++)
  61.             {
  62.                 if (schema[i].Equals(name, StringComparison.OrdinalIgnoreCase))
  63.                 {
  64.                     return i;
  65.                 }
  66.             }
  67.  
  68.             throw new IndexOutOfRangeException();
  69.         }
  70.  
  71.         public bool GetBoolean(int i)
  72.         {
  73.             throw new NotImplementedException();
  74.         }
  75.  
  76.         public byte GetByte(int i)
  77.         {
  78.             throw new NotImplementedException();
  79.         }
  80.  
  81.         public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
  82.         {
  83.             throw new NotImplementedException();
  84.         }
  85.  
  86.         public char GetChar(int i)
  87.         {
  88.             throw new NotImplementedException();
  89.         }
  90.  
  91.         public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
  92.         {
  93.             throw new NotImplementedException();
  94.         }
  95.  
  96.         public Guid GetGuid(int i)
  97.         {
  98.             throw new NotImplementedException();
  99.         }
  100.  
  101.         public short GetInt16(int i)
  102.         {
  103.             throw new NotImplementedException();
  104.         }
  105.  
  106.         public int GetInt32(int i)
  107.         {
  108.             return int.Parse(mockedValues[currentIndex][i].ToString());
  109.         }
  110.  
  111.         public long GetInt64(int i)
  112.         {
  113.             return long.Parse(mockedValues[currentIndex][i].ToString());
  114.         }
  115.  
  116.         public float GetFloat(int i)
  117.         {
  118.             throw new NotImplementedException();
  119.         }
  120.  
  121.         public double GetDouble(int i)
  122.         {
  123.             throw new NotImplementedException();
  124.         }
  125.  
  126.         public string GetString(int i)
  127.         {
  128.             return mockedValues[currentIndex][i].ToString();
  129.         }
  130.  
  131.         public decimal GetDecimal(int i)
  132.         {
  133.             throw new NotImplementedException();
  134.         }
  135.  
  136.         public DateTime GetDateTime(int i)
  137.         {
  138.             throw new NotImplementedException();
  139.         }
  140.  
  141.         public IDataReader GetData(int i)
  142.         {
  143.             throw new NotImplementedException();
  144.         }
  145.  
  146.         public bool IsDBNull(int i)
  147.         {
  148.             throw new NotImplementedException();
  149.         }
  150.  
  151.         public int FieldCount { get; private set; }
  152.  
  153.         object IDataRecord.this[int i]
  154.         {
  155.             get { throw new NotImplementedException(); }
  156.         }
  157.  
  158.         object IDataRecord.this[string name]
  159.         {
  160.             get { throw new NotImplementedException(); }
  161.         }
  162.  
  163.         public void Close()
  164.         {
  165.             throw new NotImplementedException();
  166.         }
  167.  
  168.         public DataTable GetSchemaTable()
  169.         {
  170.             throw new NotImplementedException();
  171.         }
  172.  
  173.         public bool NextResult()
  174.         {
  175.             throw new NotImplementedException();
  176.         }
  177.  
  178.         public bool Read()
  179.         {
  180.             currentIndex++;
  181.             if (currentIndex >= mockedValues.Count)
  182.             {
  183.                 return false;
  184.             }
  185.  
  186.             return true;
  187.         }
  188.  
  189.         public int Depth { get; private set; }
  190.         public bool IsClosed { get; private set; }
  191.         public int RecordsAffected { get; private set; }
  192.     }
  193. }
');