private static void AssertFilterAndOrderByQuery( ILiteQueryable <TestEntity> query, Expression <Func <TestEntity, bool> > filter = null, Expression <Func <TestEntity, object> > orderBy = null, bool ascending = true) { if (filter == null) { query.DidNotReceive().Where(Arg.Any <Expression <Func <TestEntity, bool> > >()); } else { query.Received(1).Where(filter); } if (orderBy == null) { query.DidNotReceive().OrderBy(Arg.Any <Expression <Func <TestEntity, object> > >()); query.DidNotReceive().OrderByDescending(Arg.Any <Expression <Func <TestEntity, object> > >()); } else { if (ascending) { query.Received(1).OrderBy(orderBy); } else { query.Received(1).OrderByDescending(orderBy); } } }