Skip to content

Commit 7166338

Browse files
author
Nick Craver
committed
EF6: Add initial tests
Getting this thing to even load is a royal PITA. But hey, now we can go test some scenarios.
1 parent 90ea96b commit 7166338

File tree

3 files changed

+34
-14
lines changed

3 files changed

+34
-14
lines changed

tests/MiniProfiler.Tests.AspNet/App.config

+2-14
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,10 @@
22
<configuration>
33
<configSections>
44
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
5-
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
65
</configSections>
76
<entityFramework>
8-
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework">
9-
<parameters>
10-
<parameter value="System.Data.SqlServerCe.4.0" />
11-
</parameters>
12-
</defaultConnectionFactory>
137
<providers>
14-
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
15-
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices, EntityFramework.SqlServerCompact" />
16-
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
8+
<provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
179
</providers>
1810
</entityFramework>
1911
<runtime>
@@ -26,12 +18,8 @@
2618
</runtime>
2719
<system.data>
2820
<DbProviderFactories>
29-
<remove invariant="System.Data.SqlServerCe.4.0" />
30-
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
3121
<remove invariant="System.Data.SQLite.EF6" />
32-
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
33-
<remove invariant="System.Data.SQLite" />
34-
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
22+
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description="Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
3523
</DbProviderFactories>
3624
</system.data>
3725
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System.Data.Common;
2+
using System.Data.Entity;
3+
using System.Data.Entity.Core.Common;
4+
using System.Data.Entity.Infrastructure;
5+
using StackExchange.Profiling.Data;
6+
using StackExchange.Profiling.EntityFramework6;
7+
using Xunit;
8+
using Xunit.Abstractions;
9+
10+
namespace StackExchange.Profiling.Tests
11+
{
12+
public class EF6Tests : AspNetTest
13+
{
14+
public EF6Tests(ITestOutputHelper output) : base(output)
15+
{
16+
MiniProfilerEF6.Initialize();
17+
}
18+
19+
[Fact]
20+
public void ServicesCheck()
21+
{
22+
const string providerKey = "System.Data.SQLite";
23+
24+
Assert.IsType<EFProfiledDbProviderServices>(DbConfiguration.DependencyResolver.GetService(typeof(DbProviderServices), providerKey));
25+
Assert.IsType<ProfiledDbProviderFactory>(DbConfiguration.DependencyResolver.GetService(typeof(DbProviderFactory), providerKey));
26+
Assert.IsType<EFProfiledDbProviderFactoryResolver>(DbConfiguration.DependencyResolver.GetService(typeof(IDbProviderFactoryResolver), providerKey));
27+
Assert.IsType<EFProfiledDbConnectionFactory>(DbConfiguration.DependencyResolver.GetService(typeof(IDbConnectionFactory), providerKey));
28+
}
29+
}
30+
}

tests/MiniProfiler.Tests.AspNet/MiniProfiler.Tests.AspNet.csproj

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<ProjectReference Include="..\..\src\MiniProfiler\MiniProfiler.csproj" />
1515
<ProjectReference Include="..\..\src\MiniProfiler.Providers.SqlServer\MiniProfiler.Providers.SqlServer.csproj" />
1616
<ProjectReference Include="..\..\src\MiniProfiler.Providers.SqlServerCe\MiniProfiler.Providers.SqlServerCe.csproj" />
17+
<PackageReference Include="System.Data.SQLite" Version="1.0.110" />
18+
<PackageReference Include="System.Data.SQLite.EF6" Version="1.0.110" />
1719
</ItemGroup>
1820
<PropertyGroup>
1921
<PostBuildEvent>

0 commit comments

Comments
 (0)