K
Kyle Rosenberg
Guest
I am trying to mock CloudTable for unit tests, specifically this overload for ExecuteQuerySegmentedAsync
public virtual Task<TableQuerySegment<TElement>> ExecuteQuerySegmentedAsync<TElement>(TableQuery<TElement> query, TableContinuationToken token) where TElement : ITableEntity, new();
However, I cannot compile my code due to the error: Cannot implicitly convert type 'System.Collections.Generic.List<Microsoft.Azure.Cosmos.Table.ITableEntity>' to 'System.Collections.Generic.List<ITableEntity>'
Here is the relevant code
private List<ITableEntity> rows;
public async override Task<TableQuerySegment<ITableEntity>> ExecuteQuerySegmentedAsync<ITableEntity>(TableQuery<ITableEntity> query, TableContinuationToken token)
{
var filter = query.FilterString;
List<ITableEntity> results = rows.FindAll(x => true);
var ctor = typeof(TableQuerySegment<ITableEntity>)
.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)
.FirstOrDefault(c => c.GetParameters().Count() == 1);
TableQuerySegment<ITableEntity> mock = ctor.Invoke(new object[] { results }) as TableQuerySegment<ITableEntity>;
return await Task.Run(() => mock);
}
Specifically, the error occurs on the line
List<ITableEntity> results = rows.FindAll(x => true);
even if I try casting.
Continue reading...
public virtual Task<TableQuerySegment<TElement>> ExecuteQuerySegmentedAsync<TElement>(TableQuery<TElement> query, TableContinuationToken token) where TElement : ITableEntity, new();
However, I cannot compile my code due to the error: Cannot implicitly convert type 'System.Collections.Generic.List<Microsoft.Azure.Cosmos.Table.ITableEntity>' to 'System.Collections.Generic.List<ITableEntity>'
Here is the relevant code
private List<ITableEntity> rows;
public async override Task<TableQuerySegment<ITableEntity>> ExecuteQuerySegmentedAsync<ITableEntity>(TableQuery<ITableEntity> query, TableContinuationToken token)
{
var filter = query.FilterString;
List<ITableEntity> results = rows.FindAll(x => true);
var ctor = typeof(TableQuerySegment<ITableEntity>)
.GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic)
.FirstOrDefault(c => c.GetParameters().Count() == 1);
TableQuerySegment<ITableEntity> mock = ctor.Invoke(new object[] { results }) as TableQuerySegment<ITableEntity>;
return await Task.Run(() => mock);
}
Specifically, the error occurs on the line
List<ITableEntity> results = rows.FindAll(x => true);
even if I try casting.
Continue reading...