public void Indexer4_Version_NotFound()
{
DataTable dt = new DataTable();
DataColumn dc0 = new DataColumn("Col0", typeof(Address));
dt.Columns.Add(dc0);
DataColumn dc1 = new DataColumn("Col1", typeof(Person));
dt.Columns.Add(dc1);
Person personA = new Person("Miguel");
Address addressA = new Address("X", 5);
Person personB = new Person("Chris");
dt.Rows.Add(new object[] { addressA, personA });
DataRow dr = dt.Rows[0];
try
{
object value = dr[dc0, DataRowVersion.Original];
Assert.False(true);
}
catch (VersionNotFoundException ex)
{
// There is no Original data to access
Assert.Equal(typeof(VersionNotFoundException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("Original") != -1);
}
try
{
object value = dr[dc0, DataRowVersion.Proposed];
Assert.False(true);
}
catch (VersionNotFoundException ex)
{
// There is no Proposed data to access
Assert.Equal(typeof(VersionNotFoundException), ex.GetType());
Assert.Null(ex.InnerException);
Assert.NotNull(ex.Message);
Assert.True(ex.Message.IndexOf("Proposed") != -1);
}
}