Skip to content

Commit be37423

Browse files
author
Chris Santero
committed
ensure tests work in resharper
1 parent ea0368a commit be37423

6 files changed

Lines changed: 26 additions & 215 deletions

File tree

JSONAPI.EntityFramework.Tests/App.Config

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
66
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections>
7-
<connectionStrings>
8-
<add name="TestEntities" providerName="System.Data.SqlClient" connectionString="data source=(localdb)\v11.0;initial catalog=JSONAPITestEntities;integrated security=True;multipleactiveresultsets=True;App=EntityFramework" />
9-
</connectionStrings>
107
<startup>
118
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
129
</startup>
@@ -52,8 +49,5 @@
5249
<parameter value="v11.0" />
5350
</parameters>
5451
</defaultConnectionFactory>
55-
<providers>
56-
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
57-
</providers>
5852
</entityFramework>
5953
</configuration>

JSONAPI.EntityFramework.Tests/EntityConverterTests.cs

Lines changed: 0 additions & 154 deletions
This file was deleted.

JSONAPI.EntityFramework.Tests/EntityFrameworkMaterializerTests.cs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
2+
using System.Data.Common;
23
using System.Linq;
4+
using Effort;
35
using Microsoft.VisualStudio.TestTools.UnitTesting;
46
using JSONAPI.EntityFramework.Tests.Models;
57
using FluentAssertions;
@@ -17,6 +19,11 @@ private class TestDbContext : DbContext
1719
{
1820
public DbSet<Backlink> Backlinks { get; set; }
1921
public DbSet<Post> Posts { get; set; }
22+
23+
public TestDbContext(DbConnection conn) : base(conn, true)
24+
{
25+
26+
}
2027
}
2128

2229
private class NotAnEntity
@@ -25,42 +32,40 @@ private class NotAnEntity
2532
public string Temporary { get; set; }
2633
}
2734

28-
private TestDbContext context;
29-
private Backlink b1, b2;
35+
private DbConnection _conn;
36+
private TestDbContext _context;
3037

3138
[TestInitialize]
3239
public void SetupEntities()
3340
{
34-
//- See http://stackoverflow.com/a/19130718/489116
35-
var instance = System.Data.Entity.SqlServer.SqlProviderServices.Instance;
36-
//-
37-
38-
context = new TestDbContext();
39-
//JSONAPI.EntityFramework.Json.ContractResolver.ObjectContext = context;
40-
41-
42-
// Clear it out!
43-
foreach (Backlink o in context.Backlinks) context.Backlinks.Remove(o);
44-
context.SaveChanges();
41+
_conn = DbConnectionFactory.CreateTransient();
42+
_context = new TestDbContext(_conn);
4543

46-
b1 = new Backlink
44+
var b1 = new Backlink
4745
{
4846
Url = "http://www.google.com/",
4947
Snippet = "1 Results"
5048
};
49+
_context.Backlinks.Add(b1);
5150

52-
context.SaveChanges();
51+
_context.SaveChanges();
52+
}
53+
54+
[TestCleanup]
55+
private void CleanupTest()
56+
{
57+
_context.Dispose();
5358
}
5459

5560
[TestMethod]
5661
public void GetKeyNamesStandardIdTest()
5762
{
5863
// Arrange
5964
var mockMetadataManager = new Mock<IMetadataManager>(MockBehavior.Strict);
60-
var materializer = new EntityFrameworkMaterializer(context, mockMetadataManager.Object);
65+
var materializer = new EntityFrameworkMaterializer(_context, mockMetadataManager.Object);
6166

6267
// Act
63-
IEnumerable<string> keyNames = materializer.GetKeyNames(typeof(Post));
68+
IEnumerable<string> keyNames = materializer.GetKeyNames(typeof(Post)).ToArray();
6469

6570
// Assert
6671
keyNames.Count().Should().Be(1);
@@ -72,10 +77,10 @@ public void GetKeyNamesNonStandardIdTest()
7277
{
7378
// Arrange
7479
var mockMetadataManager = new Mock<IMetadataManager>(MockBehavior.Strict);
75-
var materializer = new EntityFrameworkMaterializer(context, mockMetadataManager.Object);
80+
var materializer = new EntityFrameworkMaterializer(_context, mockMetadataManager.Object);
7681

7782
// Act
78-
IEnumerable<string> keyNames = materializer.GetKeyNames(typeof(Backlink));
83+
IEnumerable<string> keyNames = materializer.GetKeyNames(typeof(Backlink)).ToArray();
7984

8085
// Assert
8186
keyNames.Count().Should().Be(1);
@@ -87,13 +92,10 @@ public void GetKeyNamesNotAnEntityTest()
8792
{
8893
// Arrange
8994
var mockMetadataManager = new Mock<IMetadataManager>(MockBehavior.Strict);
90-
var materializer = new EntityFrameworkMaterializer(context, mockMetadataManager.Object);
95+
var materializer = new EntityFrameworkMaterializer(_context, mockMetadataManager.Object);
9196

9297
// Act
93-
Action action = () =>
94-
{
95-
materializer.GetKeyNames(typeof (NotAnEntity));
96-
};
98+
Action action = () => materializer.GetKeyNames(typeof (NotAnEntity));
9799
action.ShouldThrow<ArgumentException>().Which.Message.Should().Be("The Type NotAnEntity was not found in the DbContext with Type TestDbContext");
98100
}
99101
}

JSONAPI.EntityFramework.Tests/JSONAPI.EntityFramework.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@
116116
<Compile Include="Acceptance\AcceptanceTestsBase.cs" />
117117
<Compile Include="Acceptance\SortingTests.cs" />
118118
<Compile Include="ActionFilters\EnumerateQueryableAsyncAttributeTests.cs" />
119-
<Compile Include="EntityConverterTests.cs" />
120119
<Compile Include="EntityFrameworkMaterializerTests.cs" />
121120
<Compile Include="Helpers\TestDbAsyncEnumerable.cs" />
122121
<Compile Include="Helpers\WaitsUntilCancellationDbAsyncEnumerator.cs" />
@@ -125,7 +124,6 @@
125124
<Compile Include="Models\Author.cs" />
126125
<Compile Include="Models\Backlink.cs" />
127126
<Compile Include="Models\Comment.cs" />
128-
<Compile Include="Models\TestEntities.cs" />
129127
<Compile Include="Models\Post.cs" />
130128
<Compile Include="Properties\AssemblyInfo.cs" />
131129
<Compile Include="TestHelpers.cs" />

JSONAPI.EntityFramework.Tests/Models/TestEntities.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

JSONAPI.EntityFramework/App.config

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
<parameter value="v11.0" />
1111
</parameters>
1212
</defaultConnectionFactory>
13-
<providers>
14-
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
15-
</providers>
1613
</entityFramework>
1714
<runtime>
1815
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

0 commit comments

Comments
 (0)