Skip to content

Instantly share code, notes, and snippets.

View BartDM's full-sized avatar

Bart De Meyer BartDM

View GitHub Profile
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Query.Internal;
namespace Application
{
internal class TestAsyncQueryProvider<TEntity> : IAsyncQueryProvider
public class DbSetMockHelper
{
public static DbSet<TEntity> CreateMock<TEntity,TContext>(List<TEntity> entities, out TContext context) where TEntity : class where TContext: class
{
IQueryable<TEntity> data = entities.AsQueryable();
DbSet<TEntity> mockSet = A.Fake<DbSet<TEntity>>(d => d.Implements<IQueryable<TEntity>>().Implements<IAsyncEnumerable<TEntity>>());
A.CallTo(() => ((IAsyncEnumerable<TEntity>)mockSet).GetEnumerator())
.Returns(new TestAsyncEnumerator<TEntity>(data.GetEnumerator()));
A.CallTo(() => ((IQueryable<TEntity>)mockSet).Provider).Returns(new TestAsyncQueryProvider<TEntity>(data.Provider));
[TestFixture]
public class AsyncQueryTests
{
[Test]
public async Task GetAllBlogsAsync_orders_by_name()
{
var data = new List<Blog>
{
new Blog { Name = "BBB" },
/p:Configuration=Release
/p:OutputPath=bin
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=YOUR_PROJECT.scm.azure-mobile.net:443
/p:username="%deployUser%"
/p:password=%deployPassword%
/p:AllowUntrustedCertificate=True
/p:DeployIisAppPath=YOUR_PROJECT_WEBSITE
/p:MSDeployPublishMethod=WMSVC
/p:Configuration=Release
/p:OutputPath=bin
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=YOUR_PROJECT.scm.azure-mobile.net:443
/p:username="$USERNAME"
/p:password="A_VERY_LONG_PASSWORD"
/p:AllowUntrustedCertificate=True
/p:DeployIisAppPath=YOUR_PROJECT_WEBSITE
/p:MSDeployPublishMethod=WMSVC
/p:Configuration=Release
/p:OutputPath=bin
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=YOUR_PROJECT.scm.azure-mobile.net:443
/p:username="$USERNAME"
/p:password=%A_VERY_LONG_PASSWORD%
/p:AllowUntrustedCertificate=True
/p:DeployIisAppPath=YOUR_PROJECT_WEBSITE
/p:MSDeployPublishMethod=WMSVC
namespace LuceneWrapper.TestApp
{
public class PersonSearcher:BaseSearcher
{
public PersonSearcher(string dataFolder) : base(dataFolder)
{
}
public SearchResult SearchPeople(string searchTerm, string field)
{
using System.Collections.Generic;
using System.Linq;
namespace LuceneWrapper.TestApp
{
public class PersonWriter : BaseWriter
{
public PersonWriter(string dataFolder)
: base(dataFolder)
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LuceneWrapper.TestApp
{
public class Person
{
using System;
using System.Collections.Generic;
using System.Linq;
namespace LuceneWrapper.TestApp
{
public class Program
{
private static List<Person> people;