Skip to content

Commit a2d8f34

Browse files
authored
Merge pull request #10 from HodStudio/feature/GH-6_IncludeTestsFor45
Feature/GH-6 include tests for .net 4.5 Fixes #6
2 parents d329226 + 450c62e commit a2d8f34

23 files changed

Lines changed: 745 additions & 10 deletions

HodStudio.EntityFrameworkDiffLog.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{38726895
3535
EndProject
3636
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HodStudio.EntityFrameworkDiffLog.TestsDotNetCore", "src\HodStudio.EntityFrameworkDiffLog.TestsDotNetCore\HodStudio.EntityFrameworkDiffLog.TestsDotNetCore.csproj", "{3F3FB1E8-E0C4-4CDB-B014-F8C1321CD5CF}"
3737
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HodStudio.EntityFrameworkDiffLog.TestsDotNet45", "src\HodStudio.EntityFrameworkDiffLog.TestsDotNet45\HodStudio.EntityFrameworkDiffLog.TestsDotNet45.csproj", "{CB2F1795-261A-4348-A595-D6100242B525}"
39+
EndProject
3840
Global
3941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4042
Debug|Any CPU = Debug|Any CPU
@@ -63,6 +65,10 @@ Global
6365
{3F3FB1E8-E0C4-4CDB-B014-F8C1321CD5CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
6466
{3F3FB1E8-E0C4-4CDB-B014-F8C1321CD5CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
6567
{3F3FB1E8-E0C4-4CDB-B014-F8C1321CD5CF}.Release|Any CPU.Build.0 = Release|Any CPU
68+
{CB2F1795-261A-4348-A595-D6100242B525}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
69+
{CB2F1795-261A-4348-A595-D6100242B525}.Debug|Any CPU.Build.0 = Debug|Any CPU
70+
{CB2F1795-261A-4348-A595-D6100242B525}.Release|Any CPU.ActiveCfg = Release|Any CPU
71+
{CB2F1795-261A-4348-A595-D6100242B525}.Release|Any CPU.Build.0 = Release|Any CPU
6672
EndGlobalSection
6773
GlobalSection(SolutionProperties) = preSolution
6874
HideSolutionNode = FALSE
@@ -74,6 +80,7 @@ Global
7480
{7D814C43-15BC-4098-AF09-436BC6623781} = {CC632624-6456-4EE6-AF19-CD1B4E206C3F}
7581
{6B50016B-318B-413C-AA0F-27AD6CDBAC21} = {CC632624-6456-4EE6-AF19-CD1B4E206C3F}
7682
{3F3FB1E8-E0C4-4CDB-B014-F8C1321CD5CF} = {38726895-802C-4A8D-95E1-C0755AA611F6}
83+
{CB2F1795-261A-4348-A595-D6100242B525} = {38726895-802C-4A8D-95E1-C0755AA611F6}
7784
EndGlobalSection
7885
GlobalSection(ExtensibilityGlobals) = postSolution
7986
SolutionGuid = {86726FBC-4F6D-468F-85B8-99C7DA7DC1D7}

appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ deploy:
2222
secure: 3FtJ1e9nPNg4u0vBuJNLYgLjo1brWrpi8sgRscqsEaPAuqOmjxKqSsx/W4xMx3JH
2323
on:
2424
branch: master
25-
appveyor_repo_tag: true
25+
appveyor_repo_tag: true
26+
services:
27+
- mssql2012sp1

scripts/Build.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ echo "Complete project version: $($completeVersion)"
4949
# Restore packages
5050
echo "Restoring packages"
5151
exec { & dotnet restore }
52+
exec { & .\tools\NuGet.exe restore .\src\HodStudio.EntityFrameworkDiffLog.TestsDotNet45\HodStudio.EntityFrameworkDiffLog.TestsDotNet45.csproj -PackagesDirectory .\packages }
53+
54+
echo "Build entire solution"
55+
exec { & dotnet build -c Release }
56+
57+
echo "Tests Core version"
58+
exec { & dotnet test -c Release }
59+
60+
echo "Adjust Configuration for Tests 4.5"
61+
Remove-Item -Path ".\src\HodStudio.EntityFrameworkDiffLog.TestsDotNet45\bin\Release\HodStudio.EntityFrameworkDiffLog.TestsDotNet45.dll.config"
62+
Rename-Item -Path ".\src\HodStudio.EntityFrameworkDiffLog.TestsDotNet45\bin\Release\App.Release.config" -NewName "HodStudio.EntityFrameworkDiffLog.TestsDotNet45.dll.config"
63+
64+
echo "Tests 4.5 version"
65+
exec { & ".\packages\NUnit.ConsoleRunner.3.10.0\tools\nunit3-console.exe" ".\src\HodStudio.EntityFrameworkDiffLog.TestsDotNet45\bin\Release\HodStudio.EntityFrameworkDiffLog.TestsDotNet45.dll" }
5266

5367
# Sonar Analysis
5468
echo "Installing sonarscanner"
@@ -70,11 +84,6 @@ Catch
7084
else { echo "sonarscanner already installed" }
7185
}
7286

73-
echo "Build entire solution"
74-
exec { & dotnet build -c Release }
75-
76-
exec { & dotnet test -c Release }
77-
7887
echo "Starting Sonar for Library"
7988

8089
if ($env:APPVEYOR_PULL_REQUEST_NUMBER -ne $null)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
5+
<section name="entityFramework"
6+
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
7+
requirePermission="false"/>
8+
</configSections>
9+
<entityFramework>
10+
<providers>
11+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
12+
</providers>
13+
</entityFramework>
14+
<connectionStrings>
15+
<add name="SchoolContext" connectionString="Server=(local)\SQL2012SP1;Database=HodStudioEntityFrameworkDiffLog;User ID=sa;Password=Password12!" providerName="System.Data.SqlClient" />
16+
</connectionStrings>
17+
<runtime>
18+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
19+
<dependentAssembly>
20+
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
21+
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
22+
</dependentAssembly>
23+
</assemblyBinding>
24+
</runtime>
25+
</configuration>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<configSections>
4+
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
5+
<section name="entityFramework"
6+
type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
7+
requirePermission="false"/>
8+
</configSections>
9+
<entityFramework>
10+
<providers>
11+
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
12+
</providers>
13+
</entityFramework>
14+
<connectionStrings>
15+
<add name="SchoolContext" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=ContosoUniversity_Example_DotNet45;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />
16+
</connectionStrings>
17+
<runtime>
18+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
19+
<dependentAssembly>
20+
<assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
21+
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
22+
</dependentAssembly>
23+
</assemblyBinding>
24+
</runtime>
25+
</configuration>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using HodStudio.EntityFrameworkDiffLog.Repository;
2+
using HodStudio.EntityFrameworkDiffLog.TestsDotNet45.Data;
3+
using NUnit.Framework;
4+
5+
namespace HodStudio.EntityFrameworkDiffLog.TestsDotNet45
6+
{
7+
public class BaseTest
8+
{
9+
public static bool Initialized = false;
10+
11+
protected virtual string Operation { get; set; }
12+
13+
protected AppDbContext Context { get; private set; }
14+
15+
[OneTimeSetUp]
16+
public void OneTimeSetUp()
17+
{
18+
if (!Initialized)
19+
{
20+
LoggingContext.InitializeIdColumnNames(typeof(AppDbContext).Assembly);
21+
Initialized = true;
22+
}
23+
}
24+
25+
[SetUp]
26+
public void SetUp()
27+
{
28+
CreateContext();
29+
30+
Context.Database.Delete();
31+
Context.Database.Create();
32+
}
33+
34+
protected void CreateContext()
35+
=> Context = new AppDbContext();
36+
}
37+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using HodStudio.EntityFrameworkDiffLog.Repository;
2+
using HodStudio.EntityFrameworkDiffLog.TestsDotNet45.Model;
3+
using System.Data.Entity;
4+
5+
namespace HodStudio.EntityFrameworkDiffLog.TestsDotNet45.Data
6+
{
7+
public class AppDbContext : LoggingDbContext
8+
{
9+
public AppDbContext() : base("SchoolContext") { }
10+
11+
public DbSet<User> Users { get; set; }
12+
public DbSet<Department> Departments { get; set; }
13+
}
14+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\..\packages\EntityFramework.6.3.0\build\EntityFramework.props" Condition="Exists('..\..\packages\EntityFramework.6.3.0\build\EntityFramework.props')" />
4+
<Import Project="..\..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\..\packages\NUnit.3.12.0\build\NUnit.props')" />
5+
<Import Project="..\..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props')" />
6+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
7+
<PropertyGroup>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
10+
<ProjectGuid>{CB2F1795-261A-4348-A595-D6100242B525}</ProjectGuid>
11+
<OutputType>Library</OutputType>
12+
<AppDesignerFolder>Properties</AppDesignerFolder>
13+
<RootNamespace>HodStudio.EntityFrameworkDiffLog.TestsDotNet45</RootNamespace>
14+
<AssemblyName>HodStudio.EntityFrameworkDiffLog.TestsDotNet45</AssemblyName>
15+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
16+
<FileAlignment>512</FileAlignment>
17+
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
18+
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
19+
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
20+
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
21+
<IsCodedUITest>False</IsCodedUITest>
22+
<TestProjectType>UnitTest</TestProjectType>
23+
<NuGetPackageImportStamp>
24+
</NuGetPackageImportStamp>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
27+
<DebugSymbols>true</DebugSymbols>
28+
<DebugType>full</DebugType>
29+
<Optimize>false</Optimize>
30+
<OutputPath>bin\Debug\</OutputPath>
31+
<DefineConstants>DEBUG;TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
36+
<DebugType>pdbonly</DebugType>
37+
<Optimize>true</Optimize>
38+
<OutputPath>bin\Release\</OutputPath>
39+
<DefineConstants>TRACE</DefineConstants>
40+
<ErrorReport>prompt</ErrorReport>
41+
<WarningLevel>4</WarningLevel>
42+
</PropertyGroup>
43+
<ItemGroup>
44+
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
45+
<HintPath>..\..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.dll</HintPath>
46+
</Reference>
47+
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
48+
<HintPath>..\..\packages\EntityFramework.6.3.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
49+
</Reference>
50+
<Reference Include="Microsoft.CSharp" />
51+
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
52+
<HintPath>..\..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
53+
</Reference>
54+
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
55+
<HintPath>..\..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
56+
</Reference>
57+
<Reference Include="System" />
58+
<Reference Include="System.ComponentModel.DataAnnotations" />
59+
<Reference Include="System.Core" />
60+
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
61+
<HintPath>..\..\packages\System.ValueTuple.4.5.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
62+
</Reference>
63+
</ItemGroup>
64+
<ItemGroup>
65+
<Compile Include="BaseTest.cs" />
66+
<Compile Include="Data\AppDbContext.cs" />
67+
<Compile Include="IdGeneratedByApp\DeleteOperationsTests.cs" />
68+
<Compile Include="IdGeneratedByApp\IdGeneratedByAppBaseTests.cs" />
69+
<Compile Include="IdGeneratedByApp\InsertOperationsTests.cs" />
70+
<Compile Include="IdGeneratedByApp\UpdateOperationsTests.cs" />
71+
<Compile Include="IdGeneratedByDatabase\DeleteOperationsTests.cs" />
72+
<Compile Include="IdGeneratedByDatabase\IdGeneratedByDatabaseBaseTests.cs" />
73+
<Compile Include="IdGeneratedByDatabase\InsertOperationsTests.cs" />
74+
<Compile Include="IdGeneratedByDatabase\UpdateOperationsTests.cs" />
75+
<Compile Include="Model\Department.cs" />
76+
<Compile Include="Model\User.cs" />
77+
<Compile Include="Properties\AssemblyInfo.cs" />
78+
</ItemGroup>
79+
<ItemGroup>
80+
<None Include="App.Release.config">
81+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
82+
</None>
83+
<None Include="App.config" />
84+
<None Include="packages.config" />
85+
</ItemGroup>
86+
<ItemGroup>
87+
<ProjectReference Include="..\HodStudio.EntityFrameworkDiffLog\HodStudio.EntityFrameworkDiffLog.csproj">
88+
<Project>{0381c3d1-0fff-4e20-aa37-aacc364c2ac4}</Project>
89+
<Name>HodStudio.EntityFrameworkDiffLog</Name>
90+
</ProjectReference>
91+
</ItemGroup>
92+
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
93+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
94+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
95+
<PropertyGroup>
96+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
97+
</PropertyGroup>
98+
<Error Condition="!Exists('..\..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit3TestAdapter.3.15.1\build\net35\NUnit3TestAdapter.props'))" />
99+
<Error Condition="!Exists('..\..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit.3.12.0\build\NUnit.props'))" />
100+
<Error Condition="!Exists('..\..\packages\EntityFramework.6.3.0\build\EntityFramework.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\EntityFramework.6.3.0\build\EntityFramework.props'))" />
101+
<Error Condition="!Exists('..\..\packages\EntityFramework.6.3.0\build\EntityFramework.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\EntityFramework.6.3.0\build\EntityFramework.targets'))" />
102+
</Target>
103+
<Import Project="..\..\packages\EntityFramework.6.3.0\build\EntityFramework.targets" Condition="Exists('..\..\packages\EntityFramework.6.3.0\build\EntityFramework.targets')" />
104+
</Project>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using HodStudio.EntityFrameworkDiffLog.TestsDotNet45.Model;
2+
using NUnit.Framework;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
6+
namespace HodStudio.EntityFrameworkDiffLog.TestsDotNet45.IdGeneratedByApp
7+
{
8+
public class DeleteOperationsTests : IdGeneratedByAppBaseTests
9+
{
10+
protected override string Operation { get; set; } = "Deleted";
11+
12+
protected override Department PrepareDepartment()
13+
{
14+
var original = base.PrepareDepartment();
15+
Context.SaveChanges();
16+
17+
CreateContext();
18+
var toDelete = Context.Departments.Find(original.Id);
19+
20+
Context.Departments.Remove(toDelete);
21+
return original;
22+
}
23+
24+
protected override void ValidateDepartment(Department department)
25+
{
26+
Assert.IsNull(GetDepartment(department));
27+
}
28+
29+
[Test]
30+
public void SaveChanges()
31+
{
32+
var department = PrepareDepartment();
33+
Context.SaveChanges();
34+
Validate(department);
35+
}
36+
37+
[Test]
38+
public async Task SaveChangesAsync()
39+
{
40+
var department = PrepareDepartment();
41+
await Context.SaveChangesAsync();
42+
Validate(department);
43+
}
44+
45+
[Test]
46+
public async Task SaveChangesAsyncCancelationToken()
47+
{
48+
var department = PrepareDepartment();
49+
var cancelToken = new CancellationToken();
50+
await Context.SaveChangesAsync(cancelToken);
51+
Validate(department);
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)