Open
Description
Hi,
I'm using the MockTable.FromType method but it crash with a "getter-only" property.
My use case:
_services.DbMocks.WhenTag("MY_TAG").ReturnsTable(MockTable.FromType(new[] {
new MockedA()
{
MyLabel = "Mocked sample A",
MyOtherLabel = "Mocked sample B"
}
}, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance));
class A
{
public string MyLabel { get; set; } = string.Empty;
public string ReadOnlyLabel => MyLabel;
}
class MockedA : A
{
public string MyOtherLabel { get; set; } = string.Empty;
}
The stack trace :
Message:
System.ArgumentException: Property set method not found.
Stack Trace:
RuntimePropertyInfo.SetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
RuntimePropertyInfo.SetValue(Object obj, Object value, Object[] index)
DataRowConvertor.ToType[T](DataRow row)
DataRow.MapTo[T]()
<>c.<GetMyObjectsByProfileIds>b__28_0(DataRow row) line 1190
<>c__DisplayClass19_0`1.<ExecuteTableAsync>b__1(DataRow row)
SelectArrayIterator`2.MoveNext()
Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
DataTableConvertor.ToDataTable(IEnumerable`1 rows)
DataTableConvertor.ToDataTable(Object value)
DatabaseCommand.ExecuteInternalCommandAsync[T](Func`1 action)
DatabaseCommand.ExecuteTableAsync[T](Func`2 converter)