2018-10-22 22:05:23 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2018-12-07 00:08:16 -05:00
|
|
|
|
using System.Threading.Tasks;
|
2018-10-22 22:05:23 -04:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
2019-10-13 15:06:47 -04:00
|
|
|
|
using Microsoft.EntityFrameworkCore.Diagnostics;
|
2018-10-22 22:43:35 -04:00
|
|
|
|
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Engine.ClientProtocol;
|
|
|
|
|
using Xunit.Sdk;
|
2018-10-22 22:05:23 -04:00
|
|
|
|
|
|
|
|
|
namespace PoweredSoft.DynamicQuery.Test.Mock
|
|
|
|
|
{
|
|
|
|
|
public static class MockContextFactory
|
|
|
|
|
{
|
|
|
|
|
public static void TestContextFor(string testName, Action<MockContext> action)
|
|
|
|
|
{
|
2019-10-13 15:06:47 -04:00
|
|
|
|
var options = new DbContextOptionsBuilder<MockContext>()
|
|
|
|
|
.UseInMemoryDatabase(databaseName: testName).Options;
|
|
|
|
|
|
2019-11-27 21:08:51 -05:00
|
|
|
|
using var ctx = new MockContext(options);
|
2018-10-22 22:05:23 -04:00
|
|
|
|
action(ctx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SeedAndTestContextFor(string testName, Action<string> seedAction, Action<MockContext> action)
|
|
|
|
|
{
|
|
|
|
|
seedAction(testName);
|
|
|
|
|
TestContextFor(testName, action);
|
|
|
|
|
}
|
2018-12-07 00:08:16 -05:00
|
|
|
|
|
2018-10-22 22:05:23 -04:00
|
|
|
|
}
|
|
|
|
|
}
|