namespace UnitTests
{
using System;
using System.Collections.Generic;
using System.Data;
public class MockDataReader : IDataReader
{
private List<List<object>> mockedValues;
private List<string> schema;
private int currentIndex = -1;
public MockDataReader(List<List<object>> mockedValues, List<string> schema)
{
if (mockedValues == null)
{
throw new ArgumentNullException("mockedValues");
}
if (schema == null)
{
throw new ArgumentNullException("schema");
}
this.mockedValues = mockedValues;
this.schema = schema;
}
public void Dispose()
{
}
public string GetName(int i)
{
throw new NotImplementedException();
}
public string GetDataTypeName(int i)
{
throw new NotImplementedException();
}
public Type GetFieldType(int i)
{
throw new NotImplementedException();
}
public object GetValue(int i)
{
throw new NotImplementedException();
}
public int GetValues(object[] values)
{
throw new NotImplementedException();
}
public int GetOrdinal(string name)
{
for (int i = 0; i < schema.Count; i++)
{
if (schema[i].Equals(name, StringComparison.OrdinalIgnoreCase))
{
return i;
}
}
throw new IndexOutOfRangeException();
}
public bool GetBoolean(int i)
{
throw new NotImplementedException();
}
public byte GetByte(int i)
{
throw new NotImplementedException();
}
public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length)
{
throw new NotImplementedException();
}
public char GetChar(int i)
{
throw new NotImplementedException();
}
public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length)
{
throw new NotImplementedException();
}
public Guid GetGuid(int i)
{
throw new NotImplementedException();
}
public short GetInt16(int i)
{
throw new NotImplementedException();
}
public int GetInt32(int i)
{
return int.Parse(mockedValues[currentIndex][i].ToString());
}
public long GetInt64(int i)
{
return long.Parse(mockedValues[currentIndex][i].ToString());
}
public float GetFloat(int i)
{
throw new NotImplementedException();
}
public double GetDouble(int i)
{
throw new NotImplementedException();
}
public string GetString(int i)
{
return mockedValues[currentIndex][i].ToString();
}
public decimal GetDecimal(int i)
{
throw new NotImplementedException();
}
public DateTime GetDateTime(int i)
{
throw new NotImplementedException();
}
public IDataReader GetData(int i)
{
throw new NotImplementedException();
}
public bool IsDBNull(int i)
{
throw new NotImplementedException();
}
public int FieldCount { get; private set; }
object IDataRecord.this[int i]
{
get { throw new NotImplementedException(); }
}
object IDataRecord.this[string name]
{
get { throw new NotImplementedException(); }
}
public void Close()
{
throw new NotImplementedException();
}
public DataTable GetSchemaTable()
{
throw new NotImplementedException();
}
public bool NextResult()
{
throw new NotImplementedException();
}
public bool Read()
{
currentIndex++;
if (currentIndex >= mockedValues.Count)
{
return false;
}
return true;
}
public int Depth { get; private set; }
public bool IsClosed { get; private set; }
public int RecordsAffected { get; private set; }
}
}