diff --git a/Stove.sln b/Stove.sln index d56efe4..6876a16 100644 --- a/Stove.sln +++ b/Stove.sln @@ -1,46 +1,53 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.26228.4 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4D2BAE52-1E23-4321-BBE6-2BAC28F7B389}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{23CB5044-8ECE-4DDC-89E0-FC1B8EC9DDDF}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove", "src\Stove\Stove.xproj", "{3E6ED7B7-031B-4BB0-9682-0B87189C16FD}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5D8189AC-B744-4EE6-B590-8E09FA5E4759}" + ProjectSection(SolutionItems) = preProject + .gitignore = .gitignore + appveyor.yml = appveyor.yml + LICENSE = LICENSE + README.md = README.md + EndProjectSection EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.EntityFramework", "src\Stove.EntityFramework\Stove.EntityFramework.xproj", "{38240661-A269-4ED4-8CF0-249BF09BF52D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove", "src\Stove\Stove.csproj", "{3E6ED7B7-031B-4BB0-9682-0B87189C16FD}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.HangFire", "src\Stove.HangFire\Stove.HangFire.xproj", "{3829D36D-C8DB-4571-9A57-1821A5AC0085}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.EntityFramework", "src\Stove.EntityFramework\Stove.EntityFramework.csproj", "{38240661-A269-4ED4-8CF0-249BF09BF52D}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.NLog", "src\Stove.NLog\Stove.NLog.xproj", "{B780E514-6F9F-45A3-94B1-D1E83C6E20AC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.HangFire", "src\Stove.HangFire\Stove.HangFire.csproj", "{3829D36D-C8DB-4571-9A57-1821A5AC0085}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Tests", "test\Stove.Tests\Stove.Tests.xproj", "{DACA9BC4-BE8A-4FFE-9243-74FBBC70FA5B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.NLog", "src\Stove.NLog\Stove.NLog.csproj", "{B780E514-6F9F-45A3-94B1-D1E83C6E20AC}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.TestBase", "test\Stove.TestBase\Stove.TestBase.xproj", "{F14A49EE-4931-4A13-86E2-74DAACFEAB94}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Tests", "test\Stove.Tests\Stove.Tests.csproj", "{DACA9BC4-BE8A-4FFE-9243-74FBBC70FA5B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.EntityFramework.Tests", "test\Stove.EntityFramework.Tests\Stove.EntityFramework.Tests.xproj", "{A540038F-D692-41E6-9455-8D420E024A86}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.TestBase", "test\Stove.TestBase\Stove.TestBase.csproj", "{F14A49EE-4931-4A13-86E2-74DAACFEAB94}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5D8189AC-B744-4EE6-B590-8E09FA5E4759}" - ProjectSection(SolutionItems) = preProject - global.json = global.json - EndProjectSection +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.EntityFramework.Tests", "test\Stove.EntityFramework.Tests\Stove.EntityFramework.Tests.csproj", "{A540038F-D692-41E6-9455-8D420E024A86}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Demo.ConsoleApp", "test\Stove.Demo.ConsoleApp\Stove.Demo.ConsoleApp.csproj", "{7428E8F9-A34C-4B05-B4FF-D5A0E19F3BE1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Tests.SampleApplication", "test\Stove.Tests.SampleApplication\Stove.Tests.SampleApplication.csproj", "{1A13425B-038F-4F76-86C1-F25E5F02991C}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Demo.ConsoleApp", "test\Stove.Demo.ConsoleApp\Stove.Demo.ConsoleApp.xproj", "{7428E8F9-A34C-4B05-B4FF-D5A0E19F3BE1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Dapper", "src\Stove.Dapper\Stove.Dapper.csproj", "{5D02A99B-2E08-44C5-83FB-F607AFA2B6FF}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Tests.SampleApplication", "test\Stove.Tests.SampleApplication\Stove.Tests.SampleApplication.xproj", "{1A13425B-038F-4F76-86C1-F25E5F02991C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Mapster", "src\Stove.Mapster\Stove.Mapster.csproj", "{0213E41B-70C4-4E53-89ED-70A1753CAF4B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Dapper", "src\Stove.Dapper\Stove.Dapper.xproj", "{5D02A99B-2E08-44C5-83FB-F607AFA2B6FF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Redis", "src\Stove.Redis\Stove.Redis.csproj", "{555DA8DA-3F03-4943-B6E3-C3ED8D258969}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Mapster", "src\Stove.Mapster\Stove.Mapster.xproj", "{0213E41B-70C4-4E53-89ED-70A1753CAF4B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.RabbitMQ", "src\Stove.RabbitMQ\Stove.RabbitMQ.csproj", "{C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Redis", "src\Stove.Redis\Stove.Redis.xproj", "{555DA8DA-3F03-4943-B6E3-C3ED8D258969}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.RabbitMQ.Tests", "test\Stove.RabbitMQ.Tests\Stove.RabbitMQ.Tests.csproj", "{F024076F-A7AA-4B54-9F01-D3691A8BC988}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.RabbitMQ", "src\Stove.RabbitMQ\Stove.RabbitMQ.xproj", "{C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Mapster.Tests", "test\Stove.Mapster.Tests\Stove.Mapster.Tests.csproj", "{7182FAE3-631D-4485-AF40-69D60A8BD8B7}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.RabbitMQ.Tests", "test\Stove.RabbitMQ.Tests\Stove.RabbitMQ.Tests.xproj", "{F024076F-A7AA-4B54-9F01-D3691A8BC988}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stove.Hangfire.Tests", "test\Stove.Hangfire.Tests\Stove.Hangfire.Tests.csproj", "{44BFDB6A-ECAD-4B6C-8616-2EC182706FD1}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Stove.Mapster.Tests", "test\Stove.Mapster.Tests\Stove.Mapster.Tests.xproj", "{7182FAE3-631D-4485-AF40-69D60A8BD8B7}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stove.Dapper.Tests", "test\Stove.Dapper.Tests\Stove.Dapper.Tests.csproj", "{C4CCB48D-8B1E-4640-8B42-8E840678B120}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -108,6 +115,14 @@ Global {7182FAE3-631D-4485-AF40-69D60A8BD8B7}.Debug|Any CPU.Build.0 = Debug|Any CPU {7182FAE3-631D-4485-AF40-69D60A8BD8B7}.Release|Any CPU.ActiveCfg = Release|Any CPU {7182FAE3-631D-4485-AF40-69D60A8BD8B7}.Release|Any CPU.Build.0 = Release|Any CPU + {44BFDB6A-ECAD-4B6C-8616-2EC182706FD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44BFDB6A-ECAD-4B6C-8616-2EC182706FD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44BFDB6A-ECAD-4B6C-8616-2EC182706FD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44BFDB6A-ECAD-4B6C-8616-2EC182706FD1}.Release|Any CPU.Build.0 = Release|Any CPU + {C4CCB48D-8B1E-4640-8B42-8E840678B120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C4CCB48D-8B1E-4640-8B42-8E840678B120}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C4CCB48D-8B1E-4640-8B42-8E840678B120}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C4CCB48D-8B1E-4640-8B42-8E840678B120}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -128,5 +143,7 @@ Global {C81A0EB0-6379-46C1-9BC5-A9CBBAC0069B} = {23CB5044-8ECE-4DDC-89E0-FC1B8EC9DDDF} {F024076F-A7AA-4B54-9F01-D3691A8BC988} = {4D2BAE52-1E23-4321-BBE6-2BAC28F7B389} {7182FAE3-631D-4485-AF40-69D60A8BD8B7} = {4D2BAE52-1E23-4321-BBE6-2BAC28F7B389} + {44BFDB6A-ECAD-4B6C-8616-2EC182706FD1} = {4D2BAE52-1E23-4321-BBE6-2BAC28F7B389} + {C4CCB48D-8B1E-4640-8B42-8E840678B120} = {4D2BAE52-1E23-4321-BBE6-2BAC28F7B389} EndGlobalSection EndGlobal diff --git a/Stove.v3.ncrunchsolution b/Stove.v3.ncrunchsolution new file mode 100644 index 0000000..fcc2f69 --- /dev/null +++ b/Stove.v3.ncrunchsolution @@ -0,0 +1,16 @@ + + + True + + test\Stove.RabbitMQ.Tests\Stove.RabbitMQ.Tests.csproj + test\Stove.Mapster.Tests\Stove.Mapster.Tests.csproj + test\Stove.Tests\Stove.Tests.csproj + test\Stove.EntityFramework.Tests\Stove.EntityFramework.Tests.csproj + test\Stove.Hangfire.Tests\Stove.Hangfire.Tests.csproj + test\Stove.TestBase\Stove.TestBase.csproj + test\Stove.Tests.SampleApplication\Stove.Tests.SampleApplication.csproj + test\Stove.Dapper.Tests\Stove.Dapper.Tests.csproj + + True + + \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml index 996a5b6..3a8b234 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,32 +1,33 @@ version: 1.0.{build} +configuration: Release +image: Visual Studio 2017 RC pull_requests: do_not_increment_build_number: true -before_build: -- cmd: dotnet.exe restore + assembly_info: patch: true file: '**\AssemblyInfo.*' assembly_version: '{version}' assembly_file_version: '{version}' assembly_informational_version: '{version}' + environment: nuget_user: oguzhansoykan@outlook.com nuget_password: secure: w73Xs1Is7iK/DtAOf0XTHg== + +before_build: + - cmd: set PATH=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin;C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin;%PATH% + - cmd: nuget install nuget.commandline -source https://dotnet.myget.org/F/nuget-build -prerelease -excludeversion + - cmd: set PATH=%appveyor_build_folder%\NuGet.CommandLine\tools;%PATH% + - cmd: nuget restore Stove.sln + build: + project: Stove.sln publish_nuget: true publish_nuget_symbols: true include_nuget_references: true verbosity: minimal -after_build: -- cmd: dotnet pack "src\Stove" -c "Release" -o "nupkg/" -- cmd: dotnet pack "src\Stove.EntityFramework" -c "Release" -o "nupkg/" -- cmd: dotnet pack "src\Stove.Hangfire" -c "Release" -o "nupkg/" -- cmd: dotnet pack "src\Stove.NLog" -c "Release" -o "nupkg/" -- cmd: dotnet pack "src\Stove.Mapster" -c "Release" -o "nupkg/" -- cmd: dotnet pack "src\Stove.Redis" -c "Release" -o "nupkg/" -- cmd: dotnet pack "src\Stove.Dapper" -c "Release" -o "nupkg/" -- cmd: dotnet pack "src\Stove.RabbitMQ" -c "Release" -o "nupkg/" test: assemblies: diff --git a/global.json b/global.json deleted file mode 100644 index 9d09ab5..0000000 --- a/global.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "projects": [ "src", "test" ], - "sdk": { - "version": "1.0.0-preview2-003131" - } -} diff --git a/src/Stove.Dapper/Stove.Dapper.csproj b/src/Stove.Dapper/Stove.Dapper.csproj new file mode 100644 index 0000000..bf0bdfa --- /dev/null +++ b/src/Stove.Dapper/Stove.Dapper.csproj @@ -0,0 +1,42 @@ + + + + 0.1.0 + net452 + Stove.Dapper + Stove.Dapper + .net;framework;boilerplate;entityframework;Dapper + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + True + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + + + diff --git a/src/Stove.Dapper/Stove.Dapper.v3.ncrunchproject b/src/Stove.Dapper/Stove.Dapper.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove.Dapper/Stove.Dapper.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove.Dapper/Stove.Dapper.xproj b/src/Stove.Dapper/Stove.Dapper.xproj deleted file mode 100644 index 0a2999f..0000000 --- a/src/Stove.Dapper/Stove.Dapper.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 5d02a99b-2e08-44c5-83fb-f607afa2b6ff - Stove.Dapper - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/Stove.Dapper/project.json b/src/Stove.Dapper/project.json deleted file mode 100644 index 7c6efef..0000000 --- a/src/Stove.Dapper/project.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "version": "0.0.11-*", - - "dependencies": { - "Autofac": "4.3.0", - "Dapper": "1.50.2", - "DapperExtensions": "1.5.0", - "EntityFramework": "6.1.3", - "Stove": "0.0.11", - "Stove.EntityFramework": "0.0.11-*" - }, - - "frameworks": { - "net452": { - } - }, - - - "packOptions": { - "summary": "Dapper integration for Stove, depended on Stove.EntityFramework.", - "tags": [ - ".net", - "framework", - "boilerplate", - "entityframework", - "Dapper" - ], - "owners": [ "Oguzhan Soykan" ], - "authors": [ "Oguzhan Soykan" ], - "iconUrl": "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl": "https://github.com/osoykan/Stove", - "licenseUrl": "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/osoykan/Stove" - }, - "files": { - "mappings": { - "lib/net452/": "bin/Release/net452/Stove.Dapper.pdb" - } - } - } -} diff --git a/src/Stove.EntityFramework/Stove.EntityFramework.csproj b/src/Stove.EntityFramework/Stove.EntityFramework.csproj new file mode 100644 index 0000000..cf5d656 --- /dev/null +++ b/src/Stove.EntityFramework/Stove.EntityFramework.csproj @@ -0,0 +1,51 @@ + + + + 0.0.11 + net452 + Stove.EntityFramework + Stove.EntityFramework + .net;framework;boilerplate;entityframework + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + false + false + false + false + false + True + 0.1.0 + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Stove.EntityFramework/Stove.EntityFramework.v3.ncrunchproject b/src/Stove.EntityFramework/Stove.EntityFramework.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove.EntityFramework/Stove.EntityFramework.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove.EntityFramework/Stove.EntityFramework.xproj b/src/Stove.EntityFramework/Stove.EntityFramework.xproj deleted file mode 100644 index cffcc64..0000000 --- a/src/Stove.EntityFramework/Stove.EntityFramework.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 38240661-a269-4ed4-8cf0-249bf09bf52d - Stove.EntityFramework - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Stove.EntityFramework/project.json b/src/Stove.EntityFramework/project.json deleted file mode 100644 index b80acca..0000000 --- a/src/Stove.EntityFramework/project.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "version" : "0.0.11-*", - - "dependencies": { - "Stove": "0.0.11", - "EntityFramework": "6.1.3", - "EntityFramework.DynamicFilters": "2.6.0", - "System.Collections": "4.3.0", - "System.Collections.Immutable": "1.3.1", - "Autofac": "4.3.0", - "Autofac.Extras.IocManager": "2.0.7", - "FluentAssemblyScanner": "1.0.7" - }, - - "frameworks" : { - "net452" : { - - } - }, - - "packOptions" : { - "summary" : "EntityFramework integration for Stove.", - "tags" : [ - ".net", - "framework", - "boilerplate", - "entityframework" - ], - "owners" : ["Oguzhan Soykan"], - "authors" : ["Oguzhan Soykan"], - "iconUrl" : "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl" : "https://github.com/osoykan/Stove", - "licenseUrl" : "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance" : false, - "repository" : { - "type" : "git", - "url" : "https://github.com/osoykan/Stove" - }, - "files" : { - "mappings" : { - "lib/net452/" : "bin/Release/net452/Stove.EntityFramework.pdb" - } - } - } -} diff --git a/src/Stove.HangFire/Configurations/StoveHangfireConfigurationExtensions.cs b/src/Stove.HangFire/Configurations/StoveHangfireConfigurationExtensions.cs index ac62536..bced45c 100644 --- a/src/Stove.HangFire/Configurations/StoveHangfireConfigurationExtensions.cs +++ b/src/Stove.HangFire/Configurations/StoveHangfireConfigurationExtensions.cs @@ -1,5 +1,7 @@ using System; +using JetBrains.Annotations; + using Stove.Configuration; using Stove.Hangfire.Hangfire; @@ -7,12 +9,13 @@ namespace Stove.Hangfire.Configurations { public static class StoveHangfireConfigurationExtensions { - public static IStoveHangfireConfiguration StoveHangfire(this IModuleConfigurations configurations) + [NotNull] + public static IStoveHangfireConfiguration StoveHangfire([NotNull] this IModuleConfigurations configurations) { return configurations.StoveConfiguration.Get(); } - public static void Configure(this IStoveHangfireConfiguration configuration, Action configureAction) + public static void Configure([NotNull] this IStoveHangfireConfiguration configuration, [NotNull] Action configureAction) { configureAction(configuration); } diff --git a/src/Stove.HangFire/Hangfire/AutofacJobActivator.cs b/src/Stove.HangFire/Hangfire/AutofacJobActivator.cs index 2a0d987..bd9ac45 100644 --- a/src/Stove.HangFire/Hangfire/AutofacJobActivator.cs +++ b/src/Stove.HangFire/Hangfire/AutofacJobActivator.cs @@ -34,10 +34,7 @@ public class AutofacJobActivator : JobActivator /// public AutofacJobActivator([NotNull] ILifetimeScope lifetimeScope, bool useTaggedLifetimeScope = true) { - if (lifetimeScope == null) - { - throw new ArgumentNullException(nameof(lifetimeScope)); - } + Check.NotNull(lifetimeScope, nameof(lifetimeScope)); _lifetimeScope = lifetimeScope; _useTaggedLifetimeScope = useTaggedLifetimeScope; diff --git a/src/Stove.HangFire/Hangfire/GlobalConfigurationExtensions.cs b/src/Stove.HangFire/Hangfire/GlobalConfigurationExtensions.cs index e0396b1..e45976b 100644 --- a/src/Stove.HangFire/Hangfire/GlobalConfigurationExtensions.cs +++ b/src/Stove.HangFire/Hangfire/GlobalConfigurationExtensions.cs @@ -1,6 +1,4 @@ -using System; - -using Autofac; +using Autofac; using Hangfire; using Hangfire.Annotations; @@ -13,14 +11,8 @@ public static IGlobalConfiguration UseAutofacActivator( [NotNull] this IGlobalConfiguration configuration, [NotNull] ILifetimeScope lifetimeScope, bool useTaggedLifetimeScope = true) { - if (configuration == null) - { - throw new ArgumentNullException(nameof(configuration)); - } - if (lifetimeScope == null) - { - throw new ArgumentNullException(nameof(lifetimeScope)); - } + Check.NotNull(configuration, nameof(configuration)); + Check.NotNull(lifetimeScope, nameof(lifetimeScope)); return configuration.UseActivator(new AutofacJobActivator(lifetimeScope, useTaggedLifetimeScope)); } diff --git a/src/Stove.HangFire/Hangfire/HangfireScheduleJobManager.cs b/src/Stove.HangFire/Hangfire/HangfireScheduleJobManager.cs new file mode 100644 index 0000000..47583da --- /dev/null +++ b/src/Stove.HangFire/Hangfire/HangfireScheduleJobManager.cs @@ -0,0 +1,57 @@ +using System; +using System.Threading.Tasks; + +using Autofac.Extras.IocManager; + +using Hangfire; + +using Stove.BackgroundJobs; +using Stove.Threading.BackgrodunWorkers; + +namespace Stove.Hangfire.Hangfire +{ + public class HangfireScheduleJobManager : BackgroundWorkerBase, IScheduleJobManager, ISingletonDependency + { + private readonly IBackgroundJobConfiguration _backgroundJobConfiguration; + private readonly IStoveHangfireConfiguration _hangfireConfiguration; + + public HangfireScheduleJobManager(IStoveHangfireConfiguration hangfireConfiguration, IBackgroundJobConfiguration backgroundJobConfiguration) + { + _hangfireConfiguration = hangfireConfiguration; + _backgroundJobConfiguration = backgroundJobConfiguration; + } + + public override void Start() + { + base.Start(); + + if (_hangfireConfiguration.Server == null && _backgroundJobConfiguration.IsJobExecutionEnabled) + { + _hangfireConfiguration.Server = new BackgroundJobServer(); + } + } + + public override void WaitToStop() + { + if (_hangfireConfiguration.Server != null) + { + try + { + _hangfireConfiguration.Server.Dispose(); + } + catch (Exception ex) + { + Logger.Warn(ex.ToString(), ex); + } + } + + base.WaitToStop(); + } + + public Task ScheduleAsync(TArgs args, string interval) where TJob : IBackgroundJob + { + RecurringJob.AddOrUpdate(job => job.Execute(args), interval, TimeZoneInfo.Local); + return Task.FromResult(0); + } + } +} diff --git a/src/Stove.HangFire/Stove.HangFire.csproj b/src/Stove.HangFire/Stove.HangFire.csproj new file mode 100644 index 0000000..d6f91ff --- /dev/null +++ b/src/Stove.HangFire/Stove.HangFire.csproj @@ -0,0 +1,51 @@ + + + + 0.0.11 + net452 + Stove.HangFire + Stove.HangFire + .net;framework;boilerplate + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + false + false + false + false + false + True + 0.1.0 + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Stove.HangFire/Stove.HangFire.v3.ncrunchproject b/src/Stove.HangFire/Stove.HangFire.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove.HangFire/Stove.HangFire.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove.HangFire/Stove.HangFire.xproj b/src/Stove.HangFire/Stove.HangFire.xproj deleted file mode 100644 index afa6937..0000000 --- a/src/Stove.HangFire/Stove.HangFire.xproj +++ /dev/null @@ -1,18 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 3829d36d-c8db-4571-9a57-1821a5ac0085 - Stove.Hangfire - .\obj - .\bin\ - - - 2.0 - - - \ No newline at end of file diff --git a/src/Stove.HangFire/StoveHangFireBootstrapper.cs b/src/Stove.HangFire/StoveHangFireBootstrapper.cs index 5c2244b..58eca77 100644 --- a/src/Stove.HangFire/StoveHangFireBootstrapper.cs +++ b/src/Stove.HangFire/StoveHangFireBootstrapper.cs @@ -28,6 +28,7 @@ public override void Start() }); _backgroundWorkerManager.Add(Configuration.Resolver.Resolve()); + _backgroundWorkerManager.Add(Configuration.Resolver.Resolve()); } } } diff --git a/src/Stove.HangFire/project.json b/src/Stove.HangFire/project.json deleted file mode 100644 index 51e4e2f..0000000 --- a/src/Stove.HangFire/project.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "version": "0.0.11-*", - - "dependencies": { - "Stove": "0.0.11", - "Hangfire": "1.6.8", - "Hangfire.Core": "1.6.8", - "Hangfire.SqlServer": "1.6.8", - "Microsoft.Owin": "3.0.1", - "Microsoft.Owin.Host.SystemWeb": "3.0.1", - "Newtonsoft.Json": "9.0.1", - "Owin": "1.0", - "Autofac": "4.3.0", - "Autofac.Extras.IocManager": "2.0.7", - "FluentAssemblyScanner": "1.0.7" - }, - - "frameworks": { - "net452": { - "dependencies": { - - } - - } - }, - - "packOptions": { - "summary": "Hangfire integration for Stove.", - "tags": [ - ".net", - "framework", - "boilerplate" - ], - "owners": [ "Oguzhan Soykan" ], - "authors": [ "Oguzhan Soykan" ], - "iconUrl": "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl": "https://github.com/osoykan/Stove", - "licenseUrl": "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/osoykan/Stove" - }, - "files": { - "mappings": { - "lib/net452/": "bin/Release/net452/Stove.Hangfire.pdb" - } - } - } -} diff --git a/src/Stove.Mapster/Stove.Mapster.csproj b/src/Stove.Mapster/Stove.Mapster.csproj new file mode 100644 index 0000000..5d37fb2 --- /dev/null +++ b/src/Stove.Mapster/Stove.Mapster.csproj @@ -0,0 +1,41 @@ + + + + 0.0.11 + net452 + Stove.Mapster + Stove.Mapster + .net;framework;boilerplate;mapster + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + True + 0.1.0 + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + diff --git a/src/Stove.Mapster/Stove.Mapster.v3.ncrunchproject b/src/Stove.Mapster/Stove.Mapster.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove.Mapster/Stove.Mapster.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove.Mapster/Stove.Mapster.xproj b/src/Stove.Mapster/Stove.Mapster.xproj deleted file mode 100644 index 6dbda3e..0000000 --- a/src/Stove.Mapster/Stove.Mapster.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 0213e41b-70c4-4e53-89ed-70a1753caf4b - Stove.Mapster - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/Stove.Mapster/project.json b/src/Stove.Mapster/project.json deleted file mode 100644 index 68784e2..0000000 --- a/src/Stove.Mapster/project.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "version" : "0.0.11-*", - - "dependencies" : { - "Mapster" : "2.6.1", - "Stove" : "0.0.11" - }, - - "frameworks" : { - "net452" : { - - } - }, - - "packOptions" : { - "summary" : "Mapster object mapper integration for Stove.", - "tags" : [ - ".net", - "framework", - "boilerplate", - "mapster" - ], - "owners" : ["Oguzhan Soykan"], - "authors" : ["Oguzhan Soykan"], - "iconUrl" : "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl" : "https://github.com/osoykan/Stove", - "licenseUrl" : "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance" : false, - "repository" : { - "type" : "git", - "url" : "https://github.com/osoykan/Stove" - }, - "files" : { - "mappings" : { - "lib/net452/" : "bin/Release/net452/Stove.Mapster.pdb" - } - } - } - -} diff --git a/src/Stove.NLog/Stove.NLog.csproj b/src/Stove.NLog/Stove.NLog.csproj new file mode 100644 index 0000000..5365c69 --- /dev/null +++ b/src/Stove.NLog/Stove.NLog.csproj @@ -0,0 +1,46 @@ + + + + 0.0.11 + net452 + Stove.NLog + Stove.NLog + .net;framework;boilerplate + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + false + false + false + false + false + True + 0.1.0 + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + diff --git a/src/Stove.NLog/Stove.NLog.v3.ncrunchproject b/src/Stove.NLog/Stove.NLog.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove.NLog/Stove.NLog.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove.NLog/Stove.NLog.xproj b/src/Stove.NLog/Stove.NLog.xproj deleted file mode 100644 index 2cd7e29..0000000 --- a/src/Stove.NLog/Stove.NLog.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - b780e514-6f9f-45a3-94b1-d1e83c6e20ac - Stove.NLog - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Stove.NLog/project.json b/src/Stove.NLog/project.json deleted file mode 100644 index 9b01c4a..0000000 --- a/src/Stove.NLog/project.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "version" : "0.0.11-*", - - "dependencies": { - "Autofac": "4.3.0", - "NLog": "4.4.3", - "Stove": "0.0.11" - }, - - "frameworks" : { - "net452" : { - - } - }, - - "packOptions" : { - "summary" : "NLog integration for Stove.", - "tags" : [ - ".net", - "framework", - "boilerplate" - ], - "owners" : ["Oguzhan Soykan"], - "authors" : ["Oguzhan Soykan"], - "iconUrl" : "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl" : "https://github.com/osoykan/Stove", - "licenseUrl" : "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance" : false, - "repository" : { - "type" : "git", - "url" : "https://github.com/osoykan/Stove" - }, - "files" : { - "mappings" : { - "lib/net452/" : "bin/Release/net452/Stove.NLog.pdb" - } - } - } -} diff --git a/src/Stove.RabbitMQ/Stove.RabbitMQ.csproj b/src/Stove.RabbitMQ/Stove.RabbitMQ.csproj new file mode 100644 index 0000000..ac86a93 --- /dev/null +++ b/src/Stove.RabbitMQ/Stove.RabbitMQ.csproj @@ -0,0 +1,43 @@ + + + + 0.0.11 + net452 + Stove.RabbitMQ + Stove.RabbitMQ + .net;framework;boilerplate;Queue;RabbitMQ + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + True + 0.1.0 + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + + + diff --git a/src/Stove.RabbitMQ/Stove.RabbitMQ.v3.ncrunchproject b/src/Stove.RabbitMQ/Stove.RabbitMQ.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove.RabbitMQ/Stove.RabbitMQ.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove.RabbitMQ/Stove.RabbitMQ.xproj b/src/Stove.RabbitMQ/Stove.RabbitMQ.xproj deleted file mode 100644 index 7a065d4..0000000 --- a/src/Stove.RabbitMQ/Stove.RabbitMQ.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - c81a0eb0-6379-46c1-9bc5-a9cbbac0069b - Stove.RabbitMQ - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/Stove.RabbitMQ/StoveRabbitMQRegistrationExtensions.cs b/src/Stove.RabbitMQ/StoveRabbitMQRegistrationExtensions.cs index 0da0994..09616ba 100644 --- a/src/Stove.RabbitMQ/StoveRabbitMQRegistrationExtensions.cs +++ b/src/Stove.RabbitMQ/StoveRabbitMQRegistrationExtensions.cs @@ -25,8 +25,10 @@ public static class StoveRabbitMQRegistrationExtensions /// The rabbit mq configurer. /// [NotNull] - public static IIocBuilder UseStoveRabbitMQ([NotNull] this IIocBuilder builder, [CanBeNull] Func rabbitMQConfigurer = null) + public static IIocBuilder UseStoveRabbitMQ([NotNull] this IIocBuilder builder, [NotNull] Func rabbitMQConfigurer = null) { + Check.NotNull(rabbitMQConfigurer, nameof(rabbitMQConfigurer)); + builder .RegisterServices(r => { diff --git a/src/Stove.RabbitMQ/project.json b/src/Stove.RabbitMQ/project.json deleted file mode 100644 index 54ded3d..0000000 --- a/src/Stove.RabbitMQ/project.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "version": "0.0.11-*", - - "dependencies": { - "MassTransit": "3.5.5", - "MassTransit.Autofac": "3.5.5", - "MassTransit.RabbitMQ": "3.5.5", - "Stove": "0.0.11" - }, - - "frameworks": { - "net452": { - - } - }, - - "packOptions": { - "summary": "RabbitMQ integration for Stove.", - "tags": [ - ".net", - "framework", - "boilerplate", - "Queue", - "RabbitMQ" - ], - "owners": [ "Oguzhan Soykan" ], - "authors": [ "Oguzhan Soykan" ], - "iconUrl": "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl": "https://github.com/osoykan/Stove", - "licenseUrl": "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance": false, - "repository": { - "type": "git", - "url": "https://github.com/osoykan/Stove" - }, - "files": { - "mappings": { - "lib/net452/": "bin/Release/net452/Stove.RabbitMQ.pdb" - } - } - } -} diff --git a/src/Stove.Redis/Stove.Redis.csproj b/src/Stove.Redis/Stove.Redis.csproj new file mode 100644 index 0000000..d309805 --- /dev/null +++ b/src/Stove.Redis/Stove.Redis.csproj @@ -0,0 +1,46 @@ + + + + 0.0.11 + net452 + Stove.Redis + Stove.Redis + .net;framework;boilerplate;caching;redis + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + True + 0.1.0 + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Stove.Redis/Stove.Redis.v3.ncrunchproject b/src/Stove.Redis/Stove.Redis.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove.Redis/Stove.Redis.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove.Redis/Stove.Redis.xproj b/src/Stove.Redis/Stove.Redis.xproj deleted file mode 100644 index 55fc54d..0000000 --- a/src/Stove.Redis/Stove.Redis.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 555da8da-3f03-4943-b6e3-c3ed8d258969 - Stove.Redis - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/src/Stove.Redis/StoveRedisBootstrapper.cs b/src/Stove.Redis/StoveRedisBootstrapper.cs index d0796d2..5a10a8a 100644 --- a/src/Stove.Redis/StoveRedisBootstrapper.cs +++ b/src/Stove.Redis/StoveRedisBootstrapper.cs @@ -1,6 +1,4 @@ -using System; - -using StackExchange.Redis; +using StackExchange.Redis; using StackExchange.Redis.Extensions.Core.Configuration; using Stove.Bootstrapping; @@ -15,7 +13,7 @@ public class StoveRedisBootstrapper : StoveBootstrapper { public override void PreStart() { - if (Resolver.IsRegistered(typeof(Func))) + if (Configuration.IsConfigurerRegistered()) { Configuration.GetConfigurerIfExists().Invoke(Configuration.Modules.StoveRedis()); } diff --git a/src/Stove.Redis/project.json b/src/Stove.Redis/project.json deleted file mode 100644 index 9ae0441..0000000 --- a/src/Stove.Redis/project.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version" : "0.0.11-*", - - "dependencies": { - "StackExchange.Redis": "1.2.1", - "StackExchange.Redis.Extensions.Core": "2.1.0", - "Stove": "0.0.11" - }, - - "frameworks" : { - "net452" : { - - } - }, - - "packOptions" : { - "summary" : "Redis caching integration for Stove.", - "tags" : [ - ".net", - "framework", - "boilerplate", - "caching", - "redis" - ], - "owners" : ["Oguzhan Soykan"], - "authors" : ["Oguzhan Soykan"], - "iconUrl" : "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl" : "https://github.com/osoykan/Stove", - "licenseUrl" : "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance" : false, - "repository" : { - "type" : "git", - "url" : "https://github.com/osoykan/Stove" - }, - "files" : { - "mappings" : { - "lib/net452/" : "bin/Release/net452/Stove.Redis.pdb" - } - } - } -} diff --git a/src/Stove/BackgroundJobs/ISceduleJobManager.cs b/src/Stove/BackgroundJobs/ISceduleJobManager.cs new file mode 100644 index 0000000..21e5a67 --- /dev/null +++ b/src/Stove/BackgroundJobs/ISceduleJobManager.cs @@ -0,0 +1,26 @@ +using System.Threading.Tasks; + +using JetBrains.Annotations; + +using Stove.Threading.BackgrodunWorkers; + +namespace Stove.BackgroundJobs +{ + /// + /// Defines an interface to Scheduling and Reccurent job operations. + /// + /// + public interface IScheduleJobManager : IBackgroundWorker + { + /// + /// Schedules a job to be executed in given interval. + /// + /// The type of the job. + /// The type of the arguments. + /// The arguments. + /// The interval. + /// + [NotNull] + Task ScheduleAsync(TArgs args, [NotNull] string interval) where TJob : IBackgroundJob; + } +} diff --git a/src/Stove/Bootstrapping/IBootsrapper.cs b/src/Stove/Bootstrapping/IBootsrapper.cs index 2b2de70..f07a765 100644 --- a/src/Stove/Bootstrapping/IBootsrapper.cs +++ b/src/Stove/Bootstrapping/IBootsrapper.cs @@ -7,5 +7,7 @@ public interface IBootsrapper void Start(); void PostStart(); + + void Shutdown(); } } diff --git a/src/Stove/Bootstrapping/IStoveBootstrapperManager.cs b/src/Stove/Bootstrapping/IStoveBootstrapperManager.cs index f1eba99..1ffefc9 100644 --- a/src/Stove/Bootstrapping/IStoveBootstrapperManager.cs +++ b/src/Stove/Bootstrapping/IStoveBootstrapperManager.cs @@ -11,5 +11,7 @@ public interface IStoveBootstrapperManager IReadOnlyList Bootstrappers { get; } void StartBootstrappers([NotNull] Type starterBootStrapperType); + + void ShutdownBootstrappers(); } } diff --git a/src/Stove/Bootstrapping/StoveBootstrapper.cs b/src/Stove/Bootstrapping/StoveBootstrapper.cs index 4410bd5..cb76c63 100644 --- a/src/Stove/Bootstrapping/StoveBootstrapper.cs +++ b/src/Stove/Bootstrapping/StoveBootstrapper.cs @@ -41,6 +41,10 @@ public virtual void PostStart() { } + public virtual void Shutdown() + { + } + public virtual Assembly[] GetAdditionalAssemblies() { return new Assembly[0]; @@ -55,7 +59,8 @@ public static bool IsStoveBootstrapper(Type type) typeof(StoveBootstrapper).IsAssignableFrom(type); } - public static List FindDependedBootstrapperTypes(Type bootstrapper) + [NotNull] + public static List FindDependedBootstrapperTypes([NotNull] Type bootstrapper) { if (!IsStoveBootstrapper(bootstrapper)) { diff --git a/src/Stove/Bootstrapping/StoveBootstrapperManager.cs b/src/Stove/Bootstrapping/StoveBootstrapperManager.cs index bb70a8d..1759207 100644 --- a/src/Stove/Bootstrapping/StoveBootstrapperManager.cs +++ b/src/Stove/Bootstrapping/StoveBootstrapperManager.cs @@ -41,6 +41,15 @@ public void StartBootstrappers(Type startupBootstrapperType) sortedBootstrappers.ForEach(bootstrapper => bootstrapper.Instance.PostStart()); } + public void ShutdownBootstrappers() + { + List bootstrappers = _bootstrappers.GetSortedBootstrapperListByDependency().ToList(); + + bootstrappers.Reverse(); + + bootstrappers.ForEach(info => info.Instance.Shutdown()); + } + private void LoadAllBootstrappers() { List bootstrappers = FindAllBootstrapperTypes(); diff --git a/src/Stove/Bootstrapping/StoveKernelBootstrapper.cs b/src/Stove/Bootstrapping/StoveKernelBootstrapper.cs index 3cd9e8b..a423c3c 100644 --- a/src/Stove/Bootstrapping/StoveKernelBootstrapper.cs +++ b/src/Stove/Bootstrapping/StoveKernelBootstrapper.cs @@ -10,6 +10,7 @@ using Stove.Events.Bus; using Stove.Events.Bus.Factories; using Stove.Events.Bus.Handlers; +using Stove.Threading; using Stove.Threading.BackgrodunWorkers; namespace Stove.Bootstrapping @@ -36,6 +37,14 @@ public override void Start() ConfigureBackgroundJobs(); } + public override void Shutdown() + { + if (Configuration.BackgroundJobs.IsJobExecutionEnabled) + { + _backgroundWorkerManager.StopAndWaitToStop(); + } + } + private void ConfigureBackgroundJobs() { Configuration.GetConfigurerIfExists().Invoke(Configuration.BackgroundJobs); diff --git a/src/Stove/Configuration/IStoveStartupConfiguration.cs b/src/Stove/Configuration/IStoveStartupConfiguration.cs index c68bd2a..f246a23 100644 --- a/src/Stove/Configuration/IStoveStartupConfiguration.cs +++ b/src/Stove/Configuration/IStoveStartupConfiguration.cs @@ -3,6 +3,8 @@ using Autofac.Extras.IocManager; +using JetBrains.Annotations; + using Stove.BackgroundJobs; using Stove.Domain.Uow; using Stove.Runtime.Caching.Configuration; @@ -80,6 +82,16 @@ public interface IStoveStartupConfiguration /// /// /// + [NotNull] Func GetConfigurerIfExists(); + + /// + /// Determines whether [is configurer registered]. + /// + /// + /// + /// true if [is configurer registered]; otherwise, false. + /// + bool IsConfigurerRegistered(); } } diff --git a/src/Stove/Configuration/StoveStartupConfiguration.cs b/src/Stove/Configuration/StoveStartupConfiguration.cs index 48ff88d..4a5cb25 100644 --- a/src/Stove/Configuration/StoveStartupConfiguration.cs +++ b/src/Stove/Configuration/StoveStartupConfiguration.cs @@ -52,6 +52,11 @@ public Func GetConfigurerIfExists() }); } + public bool IsConfigurerRegistered() + { + return Resolver.IsRegistered>(); + } + public void Initialize() { Modules = Resolver.Resolve(); diff --git a/src/Stove/IO/Extensions/StreamExtensions.cs b/src/Stove/IO/Extensions/StreamExtensions.cs index 7b2339a..264fbce 100644 --- a/src/Stove/IO/Extensions/StreamExtensions.cs +++ b/src/Stove/IO/Extensions/StreamExtensions.cs @@ -1,16 +1,23 @@ using System.IO; +using JetBrains.Annotations; + namespace Stove.IO.Extensions { public static class StreamExtensions { - public static byte[] GetAllBytes(this Stream stream) + [NotNull] + public static byte[] GetAllBytes([NotNull] this Stream stream) { + byte[] streamBytes; + using (var memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); - return memoryStream.ToArray(); + streamBytes = memoryStream.ToArray(); } + + return streamBytes; } } } diff --git a/src/Stove/Linq/Extensions/QueryableExtensions.cs b/src/Stove/Linq/Extensions/QueryableExtensions.cs index 1d3f5ab..fabd399 100644 --- a/src/Stove/Linq/Extensions/QueryableExtensions.cs +++ b/src/Stove/Linq/Extensions/QueryableExtensions.cs @@ -2,61 +2,73 @@ using System.Linq; using System.Linq.Expressions; +using JetBrains.Annotations; + using Stove.Application.Dto; namespace Stove.Linq.Extensions { /// - /// Some useful extension methods for . + /// Some useful extension methods for . /// public static class QueryableExtensions { /// - /// Used for paging. Can be used as an alternative to Skip(...).Take(...) chaining. + /// Used for paging. Can be used as an alternative to Skip(...).Take(...) chaining. /// - public static IQueryable PageBy(this IQueryable query, int skipCount, int maxResultCount) + [NotNull] + public static IQueryable PageBy([NotNull] this IQueryable query, int skipCount, int maxResultCount) { - if (query == null) - { - throw new ArgumentNullException(nameof(query)); - } + Check.NotNull(query, nameof(query)); return query.Skip(skipCount).Take(maxResultCount); } /// - /// Used for paging with an object. + /// Used for paging with an object. /// /// Queryable to apply paging - /// An object implements interface - public static IQueryable PageBy(this IQueryable query, IPagedResultRequest pagedResultRequest) + /// An object implements interface + [NotNull] + public static IQueryable PageBy([NotNull] this IQueryable query, [NotNull] IPagedResultRequest pagedResultRequest) { + Check.NotNull(query, nameof(query)); + Check.NotNull(pagedResultRequest, nameof(pagedResultRequest)); + return query.PageBy(pagedResultRequest.SkipCount, pagedResultRequest.MaxResultCount); } /// - /// Filters a by given predicate if given condition is true. + /// Filters a by given predicate if given condition is true. /// /// Queryable to apply filtering /// A boolean value /// Predicate to filter the query - /// Filtered or not filtered query based on - public static IQueryable WhereIf(this IQueryable query, bool condition, Expression> predicate) + /// Filtered or not filtered query based on + [NotNull] + public static IQueryable WhereIf([NotNull] this IQueryable query, bool condition, [NotNull] Expression> predicate) { + Check.NotNull(query, nameof(query)); + Check.NotNull(predicate, nameof(predicate)); + return condition ? query.Where(predicate) : query; } /// - /// Filters a by given predicate if given condition is true. + /// Filters a by given predicate if given condition is true. /// /// Queryable to apply filtering /// A boolean value /// Predicate to filter the query - /// Filtered or not filtered query based on - public static IQueryable WhereIf(this IQueryable query, bool condition, Expression> predicate) + /// Filtered or not filtered query based on + [NotNull] + public static IQueryable WhereIf([NotNull] this IQueryable query, bool condition, [NotNull] Expression> predicate) { + Check.NotNull(query, nameof(query)); + Check.NotNull(predicate, nameof(predicate)); + return condition ? query.Where(predicate) : query; diff --git a/src/Stove/Linq/NullAsyncQueryableExecuter.cs b/src/Stove/Linq/NullAsyncQueryableExecuter.cs index d4f5e99..7a33d29 100644 --- a/src/Stove/Linq/NullAsyncQueryableExecuter.cs +++ b/src/Stove/Linq/NullAsyncQueryableExecuter.cs @@ -1,9 +1,11 @@ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading.Tasks; namespace Stove.Linq { + [ExcludeFromCodeCoverage] public class NullAsyncQueryableExecuter : IAsyncQueryableExecuter { public static NullAsyncQueryableExecuter Instance { get; } = new NullAsyncQueryableExecuter(); diff --git a/src/Stove/MQ/NullMessageBus.cs b/src/Stove/MQ/NullMessageBus.cs index f0b3632..b515af5 100644 --- a/src/Stove/MQ/NullMessageBus.cs +++ b/src/Stove/MQ/NullMessageBus.cs @@ -1,7 +1,9 @@ using System; +using System.Diagnostics.CodeAnalysis; namespace Stove.MQ { + [ExcludeFromCodeCoverage] public class NullMessageBus : IMessageBus { public static readonly NullMessageBus Instance = new NullMessageBus(); diff --git a/src/Stove/Stove.csproj b/src/Stove/Stove.csproj new file mode 100644 index 0000000..3b9b9b7 --- /dev/null +++ b/src/Stove/Stove.csproj @@ -0,0 +1,55 @@ + + + + 0.1.0 + net452 + Stove + Stove + .net;framework;boilerplate + https://raw.githubusercontent.com/osoykan/Stove/master/stove.png + https://github.com/osoykan/Stove + https://github.com/osoykan/Stove/blob/master/LICENSE + git + https://github.com/osoykan/Stove + false + false + false + false + false + false + false + false + True + + + + + lib/net452/ + true + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Stove/Stove.v3.ncrunchproject b/src/Stove/Stove.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/src/Stove/Stove.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/src/Stove/Stove.xproj b/src/Stove/Stove.xproj deleted file mode 100644 index 177d79a..0000000 --- a/src/Stove/Stove.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 3e6ed7b7-031b-4bb0-9682-0b87189c16fd - Stove - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Stove/StoveCoreRegistrationExtensions.cs b/src/Stove/StoveCoreRegistrationExtensions.cs index 8cbf0fc..f2a35aa 100644 --- a/src/Stove/StoveCoreRegistrationExtensions.cs +++ b/src/Stove/StoveCoreRegistrationExtensions.cs @@ -22,6 +22,7 @@ using Stove.Runtime.Caching.Configuration; using Stove.Runtime.Caching.Memory; using Stove.Runtime.Remoting; +using Stove.Threading; namespace Stove { @@ -277,6 +278,11 @@ private static void RegisterStoveDefaults([NotNull] this IIocBuilder builder) .RegisterServices(r => r.Register(Lifetime.Singleton)) .RegisterServices(r => r.Register(Lifetime.Singleton)) .RegisterServices(r => r.RegisterGeneric(typeof(IAmbientScopeProvider<>), typeof(DataContextAmbientScopeProvider<>))); + + builder.RegisterServices(r => r.OnDisposing += (sender, args) => + { + args.Context.Resolver.Resolve().ShutdownBootstrappers(); + }); } } } diff --git a/src/Stove/project.json b/src/Stove/project.json deleted file mode 100644 index c237510..0000000 --- a/src/Stove/project.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "version" : "0.0.11", - - "dependencies": { - "Autofac": "4.3.0", - "Autofac.Extras.IocManager.DynamicProxy": "2.0.7", - "Castle.Core": "4.0.0", - "FluentAssemblyScanner": "1.0.7", - "JetBrains.Annotations": "10.2.1", - "Newtonsoft.Json": "9.0.1", - "Nito.AsyncEx": "4.0.1", - "System.Collections.Immutable": "1.3.1" - }, - - "frameworks" : { - "net452": { - "frameworkAssemblies": { - "System.Configuration": "", - "System.Data": "", - "System.Transactions": "", - "System.Runtime": { - "type": "build" - }, - "System.Runtime.Caching": "", - "System.ComponentModel.DataAnnotations": "", - "System.Threading.Tasks": { - "type": "build" - } - } - } - }, - - "packOptions" : { - "summary" : "Application framework and main package for Stove.", - "tags" : [ - ".net", - "framework", - "boilerplate" - ], - "owners" : ["Oguzhan Soykan"], - "authors" : ["Oguzhan Soykan"], - "iconUrl" : "https://raw.githubusercontent.com/osoykan/Stove/master/stove.png", - "projectUrl" : "https://github.com/osoykan/Stove", - "licenseUrl" : "https://github.com/osoykan/Stove/blob/master/LICENSE", - "requireLicenseAcceptance" : false, - "repository" : { - "type" : "git", - "url" : "https://github.com/osoykan/Stove" - }, - "files" : { - "mappings" : { - "lib/net452/" : "bin/Release/net452/Stove.pdb" - } - } - } -} diff --git a/test/Stove.Dapper.Tests/DbContexes/DapperAppTestStoveDbContext.cs b/test/Stove.Dapper.Tests/DbContexes/DapperAppTestStoveDbContext.cs new file mode 100644 index 0000000..f9ed279 --- /dev/null +++ b/test/Stove.Dapper.Tests/DbContexes/DapperAppTestStoveDbContext.cs @@ -0,0 +1,26 @@ +using System.Data.Common; +using System.Data.Entity; + +using Stove.Dapper.Tests.Entities; +using Stove.EntityFramework.EntityFramework; + +namespace Stove.Dapper.Tests.DbContexes +{ + public class DapperAppTestStoveDbContext : StoveDbContext + { + public DapperAppTestStoveDbContext() + { + } + + public DapperAppTestStoveDbContext(DbConnection existingConnection, bool contextOwnsConnection) : base(existingConnection, contextOwnsConnection) + { + } + + public DapperAppTestStoveDbContext(DbConnection connection) + : base(connection, false) + { + } + + public virtual IDbSet Users { get; set; } + } +} diff --git a/test/Stove.Dapper.Tests/Entities/User.cs b/test/Stove.Dapper.Tests/Entities/User.cs new file mode 100644 index 0000000..d168d04 --- /dev/null +++ b/test/Stove.Dapper.Tests/Entities/User.cs @@ -0,0 +1,9 @@ +using Stove.Domain.Entities; + +namespace Stove.Dapper.Tests.Entities +{ + public class User : Entity + { + public string Name { get; set; } + } +} diff --git a/test/Stove.Dapper.Tests/Stove.Dapper.Tests.csproj b/test/Stove.Dapper.Tests/Stove.Dapper.Tests.csproj new file mode 100644 index 0000000..3057ceb --- /dev/null +++ b/test/Stove.Dapper.Tests/Stove.Dapper.Tests.csproj @@ -0,0 +1,33 @@ + + + + 0.0.1 + net461 + Stove.Dapper.Tests + Stove.Dapper.Tests + true + false + false + false + false + false + false + false + false + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/Stove.Dapper.Tests/Stove.Dapper.Tests.v3.ncrunchproject b/test/Stove.Dapper.Tests/Stove.Dapper.Tests.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/test/Stove.Dapper.Tests/Stove.Dapper.Tests.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/test/Stove.Dapper.Tests/StoveDapperApplicationTestBase.cs b/test/Stove.Dapper.Tests/StoveDapperApplicationTestBase.cs new file mode 100644 index 0000000..860b28f --- /dev/null +++ b/test/Stove.Dapper.Tests/StoveDapperApplicationTestBase.cs @@ -0,0 +1,30 @@ +using System.Reflection; + +using Autofac.Extras.IocManager; + +using Effort; + +using Stove.EntityFramework; +using Stove.TestBase; + +namespace Stove.Dapper.Tests +{ + public abstract class StoveDapperApplicationTestBase : ApplicationTestBase + { + protected StoveDapperApplicationTestBase() + { + Building(builder => + { + builder + .UseStoveEntityFramework() + .UseStoveDapper() + .UseStoveEventBus() + .UseStoveDefaultConnectionStringResolver() + .UseStoveDbContextEfTransactionStrategy(); + + builder.RegisterServices(r => r.Register(context => DbConnectionFactory.CreateTransient(), Lifetime.Singleton)); + builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly())); + }); + } + } +} diff --git a/test/Stove.Dapper.Tests/StoveDapperTestBootstrapper.cs b/test/Stove.Dapper.Tests/StoveDapperTestBootstrapper.cs new file mode 100644 index 0000000..538496b --- /dev/null +++ b/test/Stove.Dapper.Tests/StoveDapperTestBootstrapper.cs @@ -0,0 +1,11 @@ +using Stove.Bootstrapping; + +namespace Stove.Dapper.Tests +{ + [DependsOn( + typeof(StoveDapperBootstrapper) + )] + public class StoveDapperTestBootstrapper : StoveBootstrapper + { + } +} diff --git a/test/Stove.Dapper.Tests/StoveDapper_Tests.cs b/test/Stove.Dapper.Tests/StoveDapper_Tests.cs new file mode 100644 index 0000000..4066ca1 --- /dev/null +++ b/test/Stove.Dapper.Tests/StoveDapper_Tests.cs @@ -0,0 +1,28 @@ +using Shouldly; + +using Stove.Dapper.Dapper.Repositories; +using Stove.Dapper.Tests.Entities; +using Stove.Domain.Uow; + +namespace Stove.Dapper.Tests +{ + public class StoveDapper_Tests : StoveDapperApplicationTestBase + { + public StoveDapper_Tests() + { + Building(builder => { }).Ok(); + } + + //[Fact(Skip="Effort does not support Dapper queries")] + public void should_work() + { + using (IUnitOfWorkCompleteHandle uow = The().Begin()) + { + The>().Insert(new User { Name = "Oğuzhan" }); + uow.Complete(); + } + + The>().Get(1).ShouldNotBeNull(); + } + } +} diff --git a/test/Stove.Demo.ConsoleApp/SomeDomainService.cs b/test/Stove.Demo.ConsoleApp/SomeDomainService.cs index e653769..80b3fa3 100644 --- a/test/Stove.Demo.ConsoleApp/SomeDomainService.cs +++ b/test/Stove.Demo.ConsoleApp/SomeDomainService.cs @@ -3,6 +3,8 @@ using Autofac.Extras.IocManager; +using Hangfire; + using LinqKit; using MassTransit; @@ -32,6 +34,7 @@ public class SomeDomainService : ITransientDependency private readonly IRepository _animalRepository; private readonly ICacheManager _cacheManager; private readonly IBackgroundJobManager _hangfireBackgroundJobManager; + private readonly IScheduleJobManager _hangfireScheduleJobManager; private readonly IMessageBus _messageBus; private readonly IDapperRepository _personDapperRepository; private readonly IRepository _personRepository; @@ -46,7 +49,8 @@ public SomeDomainService( IDapperRepository personDapperRepository, IDapperRepository animalDapperRepository, ICacheManager cacheManager, - IMessageBus messageBus) + IMessageBus messageBus, + IScheduleJobManager hangfireScheduleJobManager) { _personRepository = personRepository; _animalRepository = animalRepository; @@ -57,6 +61,8 @@ public SomeDomainService( _animalDapperRepository = animalDapperRepository; _cacheManager = cacheManager; _messageBus = messageBus; + _hangfireScheduleJobManager = hangfireScheduleJobManager; + Logger = NullLogger.Instance; } @@ -137,10 +143,15 @@ public void DoSomeStuff() CorrelationId = NewId.NextGuid() }); - _hangfireBackgroundJobManager.EnqueueAsync(new SimpleBackgroundJobArgs + //_hangfireBackgroundJobManager.EnqueueAsync(new SimpleBackgroundJobArgs + //{ + // Message = "Oğuzhan" + //}); + + _hangfireScheduleJobManager.ScheduleAsync(new SimpleBackgroundJobArgs { Message = "Oğuzhan" - }); + }, Cron.Minutely()); Logger.Debug("Uow End!"); } diff --git a/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj b/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj new file mode 100644 index 0000000..12d5885 --- /dev/null +++ b/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.csproj @@ -0,0 +1,40 @@ + + + + 0.0.1 + net461 + Stove.Demo.ConsoleApp + Exe + Stove.Demo.ConsoleApp + false + false + false + win7-x64 + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.v3.ncrunchproject b/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.xproj b/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.xproj deleted file mode 100644 index 61ad35f..0000000 --- a/test/Stove.Demo.ConsoleApp/Stove.Demo.ConsoleApp.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - - 7428e8f9-a34c-4b05-b4ff-d5a0e19f3be1 - Stove.Demo.ConsoleApp - .\obj - .\bin\ - v4.5.2 - - - - 2.0 - - - diff --git a/test/Stove.Demo.ConsoleApp/project.json b/test/Stove.Demo.ConsoleApp/project.json deleted file mode 100644 index 5af622c..0000000 --- a/test/Stove.Demo.ConsoleApp/project.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "version": "0.0.1-*", - - "buildOptions": { - "emitEntryPoint": true - }, - - "dependencies": { - "Autofac": "4.3.0", - "Autofac.Extras.IocManager": "2.0.7", - "EntityFramework": "6.1.3", - "EntityFrameworkProfiler.Appender": "3.0.3105.0", - "FluentAssemblyScanner": "1.0.7", - "Hangfire.Core": "1.6.8", - "Hangfire.SqlServer": "1.6.8", - "LinqKit": "1.1.8", - "MassTransit": "3.5.5", - "Newtonsoft.Json": "9.0.1", - "Owin": "1.0", - "Stove": "0.0.11", - "Stove.Dapper": "0.0.11-*", - "Stove.EntityFramework": "0.0.11-*", - "Stove.HangFire": "0.0.11-*", - "Stove.Mapster": "0.0.11-*", - "Stove.NLog": "0.0.11-*", - "Stove.RabbitMQ": "1.0.0-*", - "Stove.Redis": "0.0.11-*" - }, - - "frameworks": { - "net461": { - - } - - } - - -} - - - diff --git a/test/Stove.EntityFramework.Tests/EntityFrameworkGenericRepository_Registrar_Tests.cs b/test/Stove.EntityFramework.Tests/EntityFrameworkGenericRepository_Registrar_Tests.cs index 75b2af7..0e9df25 100644 --- a/test/Stove.EntityFramework.Tests/EntityFrameworkGenericRepository_Registrar_Tests.cs +++ b/test/Stove.EntityFramework.Tests/EntityFrameworkGenericRepository_Registrar_Tests.cs @@ -38,34 +38,34 @@ public EntityFrameworkGenericRepositoryRegistrar_Tests() public void Should_Resolve_Generic_Repositories() { //Entity 1 (with default PK) - var entity1Repository = LocalResolver.Resolve>(); + var entity1Repository = The>(); entity1Repository.ShouldNotBe(null); (entity1Repository is EfRepositoryBase).ShouldBe(true); //Entity 1 (with specified PK) - var entity1RepositoryWithPk = LocalResolver.Resolve>(); + var entity1RepositoryWithPk = The>(); entity1RepositoryWithPk.ShouldNotBe(null); (entity1RepositoryWithPk is EfRepositoryBase).ShouldBe(true); //Entity 1 (with specified Repository forIMyModuleRepository ) - var entity1RepositoryWithModuleInterface = LocalResolver.Resolve>(); + var entity1RepositoryWithModuleInterface = The>(); entity1RepositoryWithModuleInterface.ShouldNotBe(null); (entity1RepositoryWithModuleInterface is MyModuleRepositoryBase).ShouldBe(true); (entity1RepositoryWithModuleInterface is EfRepositoryBase).ShouldBe(true); //Entity 1 (with specified Repository forIMyModuleRepository ) - var entity1RepositoryWithModuleInterfaceWithPk = LocalResolver.Resolve>(); + var entity1RepositoryWithModuleInterfaceWithPk = The>(); entity1RepositoryWithModuleInterfaceWithPk.ShouldNotBe(null); (entity1RepositoryWithModuleInterfaceWithPk is MyModuleRepositoryBase).ShouldBe(true); (entity1RepositoryWithModuleInterfaceWithPk is EfRepositoryBase).ShouldBe(true); //Entity 2 - var entity2Repository = LocalResolver.Resolve>(); + var entity2Repository = The>(); (entity2Repository is EfRepositoryBase).ShouldBe(true); entity2Repository.ShouldNotBe(null); //Entity 3 - var entity3Repository = LocalResolver.Resolve>(); + var entity3Repository = The>(); (entity3Repository is EfRepositoryBase).ShouldBe(true); entity3Repository.ShouldNotBe(null); } diff --git a/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.csproj b/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.csproj new file mode 100644 index 0000000..02fac3b --- /dev/null +++ b/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.csproj @@ -0,0 +1,29 @@ + + + + 0.0.1 + net461 + Stove.EntityFramework.Tests + Stove.EntityFramework.Tests + true + false + false + false + false + false + false + false + false + + + + + + + + + + + + + diff --git a/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.v3.ncrunchproject b/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.v3.ncrunchproject new file mode 100644 index 0000000..101c806 --- /dev/null +++ b/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.v3.ncrunchproject @@ -0,0 +1,8 @@ + + + + AbnormalReferenceResolution + + True + + \ No newline at end of file diff --git a/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.xproj b/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.xproj deleted file mode 100644 index 4939e82..0000000 --- a/test/Stove.EntityFramework.Tests/Stove.EntityFramework.Tests.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - a540038f-d692-41e6-9455-8d420e024a86 - Stove.EntityFramework.Tests - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Stove.EntityFramework.Tests/project.json b/test/Stove.EntityFramework.Tests/project.json deleted file mode 100644 index 95227be..0000000 --- a/test/Stove.EntityFramework.Tests/project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "0.0.1-*", - - "testRunner": "xunit", - "dependencies": { - "Autofac": "4.3.0", - "Stove.EntityFramework": "0.0.11-*", - "Stove.TestBase": "0.0.1-*" - }, - - "frameworks": { - "net461": { - - } - } -} diff --git a/test/Stove.Hangfire.Tests/HangfireApplicationTestBase.cs b/test/Stove.Hangfire.Tests/HangfireApplicationTestBase.cs new file mode 100644 index 0000000..0a1cbb6 --- /dev/null +++ b/test/Stove.Hangfire.Tests/HangfireApplicationTestBase.cs @@ -0,0 +1,23 @@ +using Hangfire.MemoryStorage; + +using Stove.TestBase; + +namespace Stove.Hangfire.Tests +{ + public class HangfireApplicationTestBase : ApplicationTestBase + { + public HangfireApplicationTestBase() + { + Building(builder => + { + builder + .UseStoveBackgroundJobs() + .UseStoveHangfire(configuration => + { + configuration.GlobalConfiguration.UseMemoryStorage(); + return configuration; + }); + }); + } + } +} diff --git a/test/Stove.Hangfire.Tests/HangfireBackgroundJobs_Tests.cs b/test/Stove.Hangfire.Tests/HangfireBackgroundJobs_Tests.cs new file mode 100644 index 0000000..0cbeed6 --- /dev/null +++ b/test/Stove.Hangfire.Tests/HangfireBackgroundJobs_Tests.cs @@ -0,0 +1,44 @@ +using System; +using System.Reflection; + +using Shouldly; + +using Stove.BackgroundJobs; + +using Xunit; + +namespace Stove.Hangfire.Tests +{ + public class HangfireBackgroundJobs_Tests : HangfireApplicationTestBase + { + public HangfireBackgroundJobs_Tests() + { + Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly())); }).Ok(); + } + + [Fact] + public void Hangfire_should_work_and_BackgroundJobManager_should_enqueue_any_backgroundjob() + { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- + var backgroundJobManager = The(); + + //----------------------------------------------------------------------------------------------------------- + // Act + //----------------------------------------------------------------------------------------------------------- + Action enqueueAction = () => + { + backgroundJobManager.EnqueueAsync(new SimpleJobArgs + { + Name = "Oguzhan" + }); + }; + + //----------------------------------------------------------------------------------------------------------- + // Assert + //----------------------------------------------------------------------------------------------------------- + enqueueAction.ShouldNotThrow(); + } + } +} diff --git a/test/Stove.Hangfire.Tests/HangfireScheduleJobs_Tests.cs b/test/Stove.Hangfire.Tests/HangfireScheduleJobs_Tests.cs new file mode 100644 index 0000000..5658239 --- /dev/null +++ b/test/Stove.Hangfire.Tests/HangfireScheduleJobs_Tests.cs @@ -0,0 +1,46 @@ +using System; +using System.Reflection; + +using Hangfire; + +using Shouldly; + +using Stove.BackgroundJobs; + +using Xunit; + +namespace Stove.Hangfire.Tests +{ + public class HangfireScheduleJobs_Tests : HangfireApplicationTestBase + { + public HangfireScheduleJobs_Tests() + { + Building(builder => { builder.RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly())); }).Ok(); + } + + [Fact] + public void Hangfire_should_work_and_ScheduleJobManager_should_schedule_any_backgroundjob() + { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- + var scheduleJobManager = The(); + + //----------------------------------------------------------------------------------------------------------- + // Act + //----------------------------------------------------------------------------------------------------------- + Action scheduleAction = () => + { + scheduleJobManager.ScheduleAsync(new SimpleJobArgs + { + Name = "Oguzhan" + }, Cron.Minutely()); + }; + + //----------------------------------------------------------------------------------------------------------- + // Assert + //----------------------------------------------------------------------------------------------------------- + scheduleAction.ShouldNotThrow(); + } + } +} diff --git a/test/Stove.Hangfire.Tests/Properties/AssemblyInfo.cs b/test/Stove.Hangfire.Tests/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b30dca0 --- /dev/null +++ b/test/Stove.Hangfire.Tests/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Stove.Hangfire.Tests")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("44bfdb6a-ecad-4b6c-8616-2ec182706fd1")] diff --git a/test/Stove.Hangfire.Tests/SimpleJob.cs b/test/Stove.Hangfire.Tests/SimpleJob.cs new file mode 100644 index 0000000..2c1ab1d --- /dev/null +++ b/test/Stove.Hangfire.Tests/SimpleJob.cs @@ -0,0 +1,22 @@ +using Autofac.Extras.IocManager; + +using Stove.BackgroundJobs; + +namespace Stove.Hangfire.Tests +{ + public class SimpleJob : BackgroundJob, ISingletonDependency + { + public int ExecutionCount { get; set; } + + public override void Execute(SimpleJobArgs args) + { + string obj = args.Name; + ExecutionCount++; + } + } + + public class SimpleJobArgs + { + public string Name { get; set; } + } +} diff --git a/test/Stove.Hangfire.Tests/Stove.Hangfire.Tests.csproj b/test/Stove.Hangfire.Tests/Stove.Hangfire.Tests.csproj new file mode 100644 index 0000000..a70e8b7 --- /dev/null +++ b/test/Stove.Hangfire.Tests/Stove.Hangfire.Tests.csproj @@ -0,0 +1,27 @@ + + + + net461 + Stove.Hangfire.Tests + Stove.Hangfire.Tests + true + false + false + false + + + + + + + + + + + + + + + + + diff --git a/test/Stove.Hangfire.Tests/Stove.Hangfire.Tests.v3.ncrunchproject b/test/Stove.Hangfire.Tests/Stove.Hangfire.Tests.v3.ncrunchproject new file mode 100644 index 0000000..101c806 --- /dev/null +++ b/test/Stove.Hangfire.Tests/Stove.Hangfire.Tests.v3.ncrunchproject @@ -0,0 +1,8 @@ + + + + AbnormalReferenceResolution + + True + + \ No newline at end of file diff --git a/test/Stove.Mapster.Tests/AutoMapping_Tests.cs b/test/Stove.Mapster.Tests/AutoMapping_Tests.cs index 55e09a8..a8e4f24 100644 --- a/test/Stove.Mapster.Tests/AutoMapping_Tests.cs +++ b/test/Stove.Mapster.Tests/AutoMapping_Tests.cs @@ -27,7 +27,7 @@ public void adapter_should_not_be_null() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - IStoveMapsterConfiguration mapsterConfiguration = LocalResolver.Resolve().StoveMapster(); + IStoveMapsterConfiguration mapsterConfiguration = The().StoveMapster(); //----------------------------------------------------------------------------------------------------------- // Act @@ -46,7 +46,7 @@ public void mapping_should_work_with_classic_way_when_only_TDestination_provided //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClass { TestProperty = "Oguzhan" }; @@ -68,7 +68,7 @@ public void auto_attibute_mapping_should_work_when_only_TDestination_provided() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClass { TestProperty = "Oguzhan" }; @@ -90,7 +90,7 @@ public void auto_attibute_mapping_should_work_when_only_TDestination_and_TSource //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClass { TestProperty = "Oguzhan" }; @@ -112,7 +112,7 @@ public void auto_attibute_mapping_should_throw_CompileException_when_target_type //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClassTargetTypeNull { TestProperty = "Oguzhan" }; @@ -133,7 +133,7 @@ public void auto_attibute_mapping_should_throw_CompileException_when_target_type //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClassTargetTypeNullTwoWay { TestProperty = "Oguzhan" }; @@ -154,7 +154,7 @@ public void auto_attribute_type_should_work_with_multiple_attributes_when_TSourc //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClassWithMultipleAttribute { TestProperty = "Oguzhan" }; @@ -179,7 +179,7 @@ public void auto_attribute_type_should_work_using_two_way_aspect() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClassTwoWay { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- @@ -203,7 +203,7 @@ public void auto_attribute_type_should_work_using_two_way_aspect_with_multiple_t //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclass = new MyClassTwoWayMultipleTypes { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- @@ -233,7 +233,7 @@ public void auto_attribute_type_should_work_with_multiple_attributes_using_to_as //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclassDto = new MyClassDto { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- @@ -257,7 +257,7 @@ public void auto_attribute_type_should_throw_CompileException_with_null_types_us //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var mapper = LocalResolver.Resolve(); + var mapper = The(); var myclassDto = new MyClassDtoNullTypes { TestProperty = "Oguzhan" }; //----------------------------------------------------------------------------------------------------------- diff --git a/test/Stove.Mapster.Tests/Stove.Mapster.Tests.csproj b/test/Stove.Mapster.Tests/Stove.Mapster.Tests.csproj new file mode 100644 index 0000000..b7b0e10 --- /dev/null +++ b/test/Stove.Mapster.Tests/Stove.Mapster.Tests.csproj @@ -0,0 +1,23 @@ + + + + net461 + Stove.Mapster.Tests + Stove.Mapster.Tests + true + false + false + false + + + + + + + + + + + + + diff --git a/test/Stove.Mapster.Tests/Stove.Mapster.Tests.v3.ncrunchproject b/test/Stove.Mapster.Tests/Stove.Mapster.Tests.v3.ncrunchproject new file mode 100644 index 0000000..101c806 --- /dev/null +++ b/test/Stove.Mapster.Tests/Stove.Mapster.Tests.v3.ncrunchproject @@ -0,0 +1,8 @@ + + + + AbnormalReferenceResolution + + True + + \ No newline at end of file diff --git a/test/Stove.Mapster.Tests/Stove.Mapster.Tests.xproj b/test/Stove.Mapster.Tests/Stove.Mapster.Tests.xproj deleted file mode 100644 index a329cf9..0000000 --- a/test/Stove.Mapster.Tests/Stove.Mapster.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 7182fae3-631d-4485-af40-69d60a8bd8b7 - Stove.Mapster.Tests - .\obj - .\bin\ - v4.6.1 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Stove.Mapster.Tests/project.json b/test/Stove.Mapster.Tests/project.json deleted file mode 100644 index 34dc557..0000000 --- a/test/Stove.Mapster.Tests/project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version" : "1.0.0-*", - - "testRunner" : "xunit", - - "dependencies" : { - "Stove.Mapster" : "0.0.11-*", - "Stove.TestBase" : "0.0.1-*" - }, - - "frameworks" : { - "net461" : { - - } - } -} diff --git a/test/Stove.RabbitMQ.Tests/RabbitMQMessageBus_Tests.cs b/test/Stove.RabbitMQ.Tests/RabbitMQMessageBus_Tests.cs index 56fa201..758645d 100644 --- a/test/Stove.RabbitMQ.Tests/RabbitMQMessageBus_Tests.cs +++ b/test/Stove.RabbitMQ.Tests/RabbitMQMessageBus_Tests.cs @@ -35,7 +35,7 @@ public void publish_object_should_work() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var messageBus = LocalResolver.Resolve(); + var messageBus = The(); var message = new { Message = "Hi" }; //----------------------------------------------------------------------------------------------------------- @@ -55,7 +55,7 @@ public void publish_with_object_should_work() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var messageBus = LocalResolver.Resolve(); + var messageBus = The(); var message = new { Message = "Hi" }; //----------------------------------------------------------------------------------------------------------- @@ -75,7 +75,7 @@ public void publish_with_TMessage_should_work() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var messageBus = LocalResolver.Resolve(); + var messageBus = The(); var message = new RabbitMqTestMessage { Message = "Hi" }; //----------------------------------------------------------------------------------------------------------- @@ -95,7 +95,7 @@ public void publish_with_TMessage_as_object_should_work() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var messageBus = LocalResolver.Resolve(); + var messageBus = The(); var message = new { Message = "Hi" }; //----------------------------------------------------------------------------------------------------------- @@ -115,7 +115,7 @@ public void publish_object_with_type_should_work() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - var messageBus = LocalResolver.Resolve(); + var messageBus = The(); var message = new RabbitMqTestMessage { Message = "Hi" }; //----------------------------------------------------------------------------------------------------------- diff --git a/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.csproj b/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.csproj new file mode 100644 index 0000000..db164df --- /dev/null +++ b/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.csproj @@ -0,0 +1,24 @@ + + + + net461 + Stove.RabbitMQ.Tests + Stove.RabbitMQ.Tests + true + false + false + false + + + + + + + + + + + + + + diff --git a/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.v3.ncrunchproject b/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.v3.ncrunchproject new file mode 100644 index 0000000..101c806 --- /dev/null +++ b/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.v3.ncrunchproject @@ -0,0 +1,8 @@ + + + + AbnormalReferenceResolution + + True + + \ No newline at end of file diff --git a/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.xproj b/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.xproj deleted file mode 100644 index 4b92522..0000000 --- a/test/Stove.RabbitMQ.Tests/Stove.RabbitMQ.Tests.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - f024076f-a7aa-4b54-9f01-d3691a8bc988 - Stove.RabbitMQ.Tests - .\obj - .\bin\ - v4.6.1 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Stove.RabbitMQ.Tests/StoveRabbitMQConfiguration_Tests.cs b/test/Stove.RabbitMQ.Tests/StoveRabbitMQConfiguration_Tests.cs index a518243..1085206 100644 --- a/test/Stove.RabbitMQ.Tests/StoveRabbitMQConfiguration_Tests.cs +++ b/test/Stove.RabbitMQ.Tests/StoveRabbitMQConfiguration_Tests.cs @@ -28,7 +28,7 @@ public StoveRabbitMQConfiguration_Tests() [Fact] public void extension_should_be_instantiatable() { - LocalResolver.Resolve().StoveRabbitMQ().ShouldNotBeNull(); + The().StoveRabbitMQ().ShouldNotBeNull(); } [Fact] @@ -37,7 +37,7 @@ public void configuration_settings_should_work() //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- - IStoveRabbitMQConfiguration configuration = LocalResolver.Resolve().StoveRabbitMQ(); + IStoveRabbitMQConfiguration configuration = The().StoveRabbitMQ(); configuration.HostAddress = "127.0.0.1"; configuration.MaxRetryCount = 1; configuration.Password = "123456"; @@ -48,7 +48,7 @@ public void configuration_settings_should_work() //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- - var configurationFromIoc = LocalResolver.Resolve(); + var configurationFromIoc = The(); //----------------------------------------------------------------------------------------------------------- // Assert diff --git a/test/Stove.RabbitMQ.Tests/project.json b/test/Stove.RabbitMQ.Tests/project.json deleted file mode 100644 index 270ceab..0000000 --- a/test/Stove.RabbitMQ.Tests/project.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "version" : "1.0.0-*", - - "testRunner" : "xunit", - - "dependencies": { - "Stove": "0.0.11", - "Stove.RabbitMQ": "0.0.11-*", - "Stove.TestBase": "0.0.1-*" - }, - - "frameworks" : { - "net461" : { - - } - } -} diff --git a/test/Stove.TestBase/ApplicationTestBase.cs b/test/Stove.TestBase/ApplicationTestBase.cs index e737095..7a7b501 100644 --- a/test/Stove.TestBase/ApplicationTestBase.cs +++ b/test/Stove.TestBase/ApplicationTestBase.cs @@ -22,7 +22,7 @@ protected ApplicationTestBase() }); } - protected TestStoveSession TestStoveSession => LocalResolver.Resolve(); + protected TestStoveSession TestStoveSession => The(); protected override void PreBuild() { diff --git a/test/Stove.TestBase/Stove.TestBase.csproj b/test/Stove.TestBase/Stove.TestBase.csproj new file mode 100644 index 0000000..099feda --- /dev/null +++ b/test/Stove.TestBase/Stove.TestBase.csproj @@ -0,0 +1,35 @@ + + + + 0.0.1 + net452 + Stove.TestBase + Stove.TestBase + false + false + false + false + false + false + false + false + + + + + + + + + + + + + + + + + + + + diff --git a/test/Stove.TestBase/Stove.TestBase.v3.ncrunchproject b/test/Stove.TestBase/Stove.TestBase.v3.ncrunchproject new file mode 100644 index 0000000..6800b4a --- /dev/null +++ b/test/Stove.TestBase/Stove.TestBase.v3.ncrunchproject @@ -0,0 +1,5 @@ + + + True + + \ No newline at end of file diff --git a/test/Stove.TestBase/Stove.TestBase.xproj b/test/Stove.TestBase/Stove.TestBase.xproj deleted file mode 100644 index 78672a1..0000000 --- a/test/Stove.TestBase/Stove.TestBase.xproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - f14a49ee-4931-4a13-86e2-74daacfeab94 - Stove.TestBase - .\obj - .\bin\ - - - - 2.0 - - - \ No newline at end of file diff --git a/test/Stove.TestBase/TestBaseWithLocalIocResolver.cs b/test/Stove.TestBase/TestBaseWithLocalIocResolver.cs index d4ab33b..39a1357 100644 --- a/test/Stove.TestBase/TestBaseWithLocalIocResolver.cs +++ b/test/Stove.TestBase/TestBaseWithLocalIocResolver.cs @@ -14,6 +14,11 @@ protected TestBaseWithLocalIocResolver() IocBuilder = Autofac.Extras.IocManager.IocBuilder.New.UseAutofacContainerBuilder(); } + public void Dispose() + { + LocalResolver?.Dispose(); + } + protected TestBaseWithLocalIocResolver Building(Action builderAction) { builderAction(IocBuilder); @@ -35,9 +40,9 @@ protected virtual void PostBuild() { } - public void Dispose() + protected T The() { - LocalResolver?.Dispose(); + return LocalResolver.Resolve(); } } } diff --git a/test/Stove.TestBase/project.json b/test/Stove.TestBase/project.json deleted file mode 100644 index 506c2ce..0000000 --- a/test/Stove.TestBase/project.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "version": "0.0.1-*", - - "dependencies": { - "dotnet-test-xunit": "2.2.0-preview2-build1029", - "NSubstitute": "1.10.0", - "Shouldly": "2.8.2", - "Stove": "0.0.11", - "FluentAssemblyScanner": "1.0.7", - "xunit": "2.2.0" - }, - - "frameworks": { - "net452": { - - } - } -} diff --git a/test/Stove.Tests.SampleApplication/Application/Users/UserAppService.cs b/test/Stove.Tests.SampleApplication/Application/Users/UserAppService.cs new file mode 100644 index 0000000..53f1ec8 --- /dev/null +++ b/test/Stove.Tests.SampleApplication/Application/Users/UserAppService.cs @@ -0,0 +1,29 @@ +using JetBrains.Annotations; + +using Stove.Application.Services; +using Stove.Domain.Repositories; +using Stove.Tests.SampleApplication.Domain.Entities; + +namespace Stove.Tests.SampleApplication.Application +{ + public class UserAppService : ApplicationService, IUserAppService + { + private readonly IRepository _userRepository; + + public UserAppService(IRepository userRepository) + { + _userRepository = userRepository; + } + + public User GetUserByName(string name) + { + return _userRepository.FirstOrDefault(x => x.Name == name); + } + } + + public interface IUserAppService + { + [CanBeNull] + User GetUserByName([NotNull] string name); + } +} diff --git a/test/Stove.Tests.SampleApplication/Application/Users/UserAppService_Tests.cs b/test/Stove.Tests.SampleApplication/Application/Users/UserAppService_Tests.cs new file mode 100644 index 0000000..66f476e --- /dev/null +++ b/test/Stove.Tests.SampleApplication/Application/Users/UserAppService_Tests.cs @@ -0,0 +1,32 @@ +using Shouldly; + +using Stove.Domain.Uow; +using Stove.Tests.SampleApplication.Domain.Entities; + +using Xunit; + +namespace Stove.Tests.SampleApplication.Application +{ + public class UserAppService_Tests : SampleApplicationTestBase + { + public UserAppService_Tests() + { + Building(builder => { }).Ok(); + } + + [Fact] + public void ApplicationService_should_work_with_repository() + { + using (IUnitOfWorkCompleteHandle uow = The().Begin()) + { + var userAppService = The(); + + User user = userAppService.GetUserByName("Oğuzhan"); + + user.ShouldNotBeNull(); + + uow.Complete(); + } + } + } +} diff --git a/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs b/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs index daaf807..e0f4843 100644 --- a/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs +++ b/test/Stove.Tests.SampleApplication/AutoMapping_Tests.cs @@ -14,7 +14,7 @@ public void auto_object_mapping_should_work() { Building(builder => { }).Ok(); - var mapper = LocalResolver.Resolve(); + var mapper = The(); var person = new Person { Name = "Oğuzhan" }; diff --git a/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs b/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs index 4d3e9a8..1418642 100644 --- a/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs +++ b/test/Stove.Tests.SampleApplication/BasicRepository_Tests.cs @@ -24,8 +24,8 @@ public BasicRepository_Tests() [Fact] public void firstordefault_should_work() { - var uowManager = LocalResolver.Resolve(); - var userRepository = LocalResolver.Resolve>(); + var uowManager = The(); + var userRepository = The>(); using (IUnitOfWorkCompleteHandle uow = uowManager.Begin()) { @@ -39,8 +39,8 @@ public void firstordefault_should_work() [Fact] public void uow_rollback_should_work_with_repository_insert() { - var uowManager = LocalResolver.Resolve(); - var userRepository = LocalResolver.Resolve>(); + var uowManager = The(); + var userRepository = The>(); using (IUnitOfWorkCompleteHandle uow = uowManager.Begin()) { @@ -63,8 +63,8 @@ public void uow_rollback_should_work_with_repository_insert() [Fact] public void uow_complete_handle_eventbus_should_work_with_repository_insert() { - var uowManager = LocalResolver.Resolve(); - var userRepository = LocalResolver.Resolve>(); + var uowManager = The(); + var userRepository = The>(); using (IUnitOfWorkCompleteHandle uow = uowManager.Begin()) { @@ -94,8 +94,8 @@ public void uow_complete_handle_eventbus_should_work_with_repository_insert() [Fact] public void uow_complete_handle_eventbus_should_work_with_repository_insert2() { - var uowManager = LocalResolver.Resolve(); - var userRepository = LocalResolver.Resolve>(); + var uowManager = The(); + var userRepository = The>(); using (IUnitOfWorkCompleteHandle uow = uowManager.Begin()) { diff --git a/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs b/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs index 2552dbb..7d5bbd6 100644 --- a/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs +++ b/test/Stove.Tests.SampleApplication/SampleApplicationTestBase.cs @@ -81,7 +81,7 @@ protected virtual void CreateInitialData() public void UsingDbContext(Action action) { - using (var context = LocalResolver.Resolve()) + using (var context = The()) { context.DisableAllFilters(); action(context); @@ -93,7 +93,7 @@ public T UsingDbContext(Func func) { T result; - using (var context = LocalResolver.Resolve()) + using (var context = The()) { context.DisableAllFilters(); result = func(context); @@ -107,7 +107,7 @@ public async Task UsingDbContextAsync(Func()) + using (var context = The()) { context.DisableAllFilters(); result = await func(context); diff --git a/test/Stove.Tests.SampleApplication/Session/Session_Tests.cs b/test/Stove.Tests.SampleApplication/Session/Session_Tests.cs index 5d68480..d15f38f 100644 --- a/test/Stove.Tests.SampleApplication/Session/Session_Tests.cs +++ b/test/Stove.Tests.SampleApplication/Session/Session_Tests.cs @@ -14,7 +14,7 @@ public Session_Tests() { Building(builder => { }).Ok(); - _session = LocalResolver.Resolve(); + _session = The(); } [Fact] diff --git a/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.csproj b/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.csproj new file mode 100644 index 0000000..6f7c54f --- /dev/null +++ b/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.csproj @@ -0,0 +1,28 @@ + + + + net461 + Stove.Tests.SampleApplication + Stove.Tests.SampleApplication + true + false + false + false + + + + + + + + + + + + + + + + + + diff --git a/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.v3.ncrunchproject b/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.v3.ncrunchproject new file mode 100644 index 0000000..101c806 --- /dev/null +++ b/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.v3.ncrunchproject @@ -0,0 +1,8 @@ + + + + AbnormalReferenceResolution + + True + + \ No newline at end of file diff --git a/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.xproj b/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.xproj deleted file mode 100644 index 312eec1..0000000 --- a/test/Stove.Tests.SampleApplication/Stove.Tests.SampleApplication.xproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 1a13425b-038f-4f76-86c1-f25e5f02991c - Stove.Tests.SampleApplication - .\obj - .\bin\ - v4.5.2 - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Stove.Tests.SampleApplication/UnitOfWorkNested_Tests.cs b/test/Stove.Tests.SampleApplication/UnitOfWorkNested_Tests.cs index c35cdf4..4b91d82 100644 --- a/test/Stove.Tests.SampleApplication/UnitOfWorkNested_Tests.cs +++ b/test/Stove.Tests.SampleApplication/UnitOfWorkNested_Tests.cs @@ -15,7 +15,7 @@ public class UnitOfWorkNested_Tests : SampleApplicationTestBase public UnitOfWorkNested_Tests() { Building(builder => { }).Ok(); - _unitOfWorkManager = LocalResolver.Resolve(); + _unitOfWorkManager = The(); } [Fact] diff --git a/test/Stove.Tests.SampleApplication/project.json b/test/Stove.Tests.SampleApplication/project.json deleted file mode 100644 index 834f1cc..0000000 --- a/test/Stove.Tests.SampleApplication/project.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "1.0.0-*", - - "testRunner": "xunit", - - "dependencies": { - "Effort.EF6": "1.3.0", - "Stove.EntityFramework": "0.0.11-*", - "Stove.Mapster": "0.0.11-*", - "Stove.TestBase": "0.0.1-*" - }, - - "frameworks": { - "net461": {} - } -} diff --git a/test/Stove.Tests/Bootstrapping/BootstrapperAssemblyFinder_Tests.cs b/test/Stove.Tests/Bootstrapping/BootstrapperAssemblyFinder_Tests.cs index a479cb0..661fb78 100644 --- a/test/Stove.Tests/Bootstrapping/BootstrapperAssemblyFinder_Tests.cs +++ b/test/Stove.Tests/Bootstrapping/BootstrapperAssemblyFinder_Tests.cs @@ -17,6 +17,9 @@ public class BootstrapperAssemblyFinder_Tests : TestBaseWithLocalIocResolver [Fact] public void Should_Get_Bootstrapper_And_Additional_Assemblies() { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- Building(builder => { builder @@ -25,12 +28,17 @@ public void Should_Get_Bootstrapper_And_Additional_Assemblies() }) .Ok(); - //Act - List assemblies = LocalResolver.Resolve().GetAllAssemblies(); + //----------------------------------------------------------------------------------------------------------- + // Act + //----------------------------------------------------------------------------------------------------------- + var sut = The(); - //Assert - assemblies.Count.ShouldBe(3); + //----------------------------------------------------------------------------------------------------------- + // Assert + //----------------------------------------------------------------------------------------------------------- + List assemblies = sut.GetAllAssemblies(); + assemblies.Count.ShouldBe(3); assemblies.Any(a => a == typeof(MyStartupBootstrapper).Assembly).ShouldBeTrue(); assemblies.Any(a => a == typeof(StoveKernelBootstrapper).Assembly).ShouldBeTrue(); assemblies.Any(a => a == typeof(FactAttribute).Assembly).ShouldBeTrue(); diff --git a/test/Stove.Tests/Bootstrapping/Bootstrapping_Tests.cs b/test/Stove.Tests/Bootstrapping/Bootstrapping_Tests.cs index 4462e13..2d6d7eb 100644 --- a/test/Stove.Tests/Bootstrapping/Bootstrapping_Tests.cs +++ b/test/Stove.Tests/Bootstrapping/Bootstrapping_Tests.cs @@ -14,18 +14,27 @@ public class Bootstrapping_Tests : TestBaseWithLocalIocResolver [Fact] public void events_should_called_once() { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- Building(builder => - { - builder - .UseStoveWithNullables(typeof(MyTestBootstrapper)) - .RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly())); - }) - .Ok(); - - var testModule = LocalResolver.Resolve(); - var otherModule = LocalResolver.Resolve(); - var anotherModule = LocalResolver.Resolve(); - + { + builder + .UseStoveWithNullables(typeof(MyTestBootstrapper)) + .RegisterServices(r => r.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly())); + }) + .Ok(); + + //----------------------------------------------------------------------------------------------------------- + // Act + //----------------------------------------------------------------------------------------------------------- + var testModule = The(); + var otherModule = The(); + var anotherModule = The(); + + //----------------------------------------------------------------------------------------------------------- + // Assert + //----------------------------------------------------------------------------------------------------------- testModule.PreStartCount.ShouldBe(1); testModule.StartCount.ShouldBe(1); testModule.PostStartCount.ShouldBe(1); diff --git a/test/Stove.Tests/Domain/Uow/UowManager_Tests.cs b/test/Stove.Tests/Domain/Uow/UowManager_Tests.cs index fd62b27..a1656d6 100644 --- a/test/Stove.Tests/Domain/Uow/UowManager_Tests.cs +++ b/test/Stove.Tests/Domain/Uow/UowManager_Tests.cs @@ -26,7 +26,7 @@ public void Should_Call_Uow_Methods() builder.RegisterServices(r => r.Register(context => fakeUow, Lifetime.Singleton)); }).Ok(); - var uowManager = LocalResolver.Resolve(); + var uowManager = The(); //Starting the first uow using (IUnitOfWorkCompleteHandle uow1 = uowManager.Begin()) diff --git a/test/Stove.Tests/Events/Bus/Exceptions/ExceptionDataTests.cs b/test/Stove.Tests/Events/Bus/Exceptions/ExceptionDataTests.cs new file mode 100644 index 0000000..bca045e --- /dev/null +++ b/test/Stove.Tests/Events/Bus/Exceptions/ExceptionDataTests.cs @@ -0,0 +1,20 @@ +using Shouldly; + +using Stove.Events.Bus.Exceptions; + +using Xunit; + +namespace Stove.Tests.Events.Bus.Exceptions +{ + public class ExceptionDataTests + { + [Fact] + public void should_be_instantiatable() + { + var exceptionData = new ExceptionData(new StoveException("whatever")); + + exceptionData.ShouldNotBeNull(); + exceptionData.Exception.ShouldBeOfType(); + } + } +} \ No newline at end of file diff --git a/test/Stove.Tests/IO/Extensions/StreamExtensions_Tests.cs b/test/Stove.Tests/IO/Extensions/StreamExtensions_Tests.cs new file mode 100644 index 0000000..cdb52f8 --- /dev/null +++ b/test/Stove.Tests/IO/Extensions/StreamExtensions_Tests.cs @@ -0,0 +1,26 @@ +using System.IO; +using System.Text; + +using Shouldly; + +using Stove.IO.Extensions; + +using Xunit; + +namespace Stove.Tests.IO.Extensions +{ + public class StreamExtensions_Tests + { + [Fact] + public void GetAllBytes_should_work() + { + byte[] bytes; + using (var whatEverStream = new MemoryStream(Encoding.UTF8.GetBytes("whatever"))) + { + bytes = whatEverStream.GetAllBytes(); + } + + bytes.ShouldNotBeNull(); + } + } +} diff --git a/test/Stove.Tests/Linq/Extensions/QueryableExtensionsTests.cs b/test/Stove.Tests/Linq/Extensions/QueryableExtensionsTests.cs new file mode 100644 index 0000000..85a229c --- /dev/null +++ b/test/Stove.Tests/Linq/Extensions/QueryableExtensionsTests.cs @@ -0,0 +1,85 @@ +using System.Collections.Generic; +using System.Linq; + +using Shouldly; + +using Stove.Application.Dto; +using Stove.Linq.Extensions; + +using Xunit; + +namespace Stove.Tests.Linq.Extensions +{ + public class QueryableExtensionsTests + { + [Fact] + public void PageBy_with_PagedResultRequestDto_should_work() + { + var products = new List + { + new Product { Name = "Oguzhan" }, + new Product { Name = "Soykan" } + }; + + IQueryable productsQueryable = products.AsQueryable(); + + IQueryable pagedQueryable = productsQueryable.PageBy(new PagedResultRequestDto { MaxResultCount = 1, SkipCount = 0 }); + + pagedQueryable.ToList().Count.ShouldBe(1); + } + + [Fact] + public void PageBy_with_skip_and_maxresultcount_should_work() + { + var products = new List + { + new Product { Name = "Oguzhan" }, + new Product { Name = "Soykan" } + }; + + IQueryable productsQueryable = products.AsQueryable(); + + IQueryable pagedQueryable = productsQueryable.PageBy(0, 2); + + pagedQueryable.ToList().Count.ShouldBe(2); + } + + [Fact] + public void WhereIf_should_work() + { + var products = new List + { + new Product { Name = "Oguzhan" }, + new Product { Name = "Soykan" } + }; + + IQueryable productsQueryable = products.AsQueryable(); + + IQueryable pagedQueryable = productsQueryable.WhereIf(products.Count == 2, (product, i) => product.Name == "Oguzhan"); + + pagedQueryable.ToList().Count.ShouldBe(1); + } + + + [Fact] + public void WhereIf_should_wor2k() + { + var products = new List + { + new Product { Name = "Oguzhan" }, + new Product { Name = "Soykan" } + }; + + IQueryable productsQueryable = products.AsQueryable(); + + IQueryable pagedQueryable = productsQueryable.WhereIf(products.Count == 2, product => product.Name == "Oguzhan"); + + pagedQueryable.ToList().Count.ShouldBe(1); + } + + private class Product + { + public string Name { get; set; } + } + } +} diff --git a/test/Stove.Tests/ObjectMapping/NullObjectMapper_Tests.cs b/test/Stove.Tests/ObjectMapping/NullObjectMapper_Tests.cs new file mode 100644 index 0000000..0e921ec --- /dev/null +++ b/test/Stove.Tests/ObjectMapping/NullObjectMapper_Tests.cs @@ -0,0 +1,68 @@ +using System; + +using Shouldly; + +using Stove.ObjectMapping; +using Stove.TestBase; + +using Xunit; + +namespace Stove.Tests.ObjectMapping +{ + public class NullObjectMapper_Tests : TestBaseWithLocalIocResolver + { + public NullObjectMapper_Tests() + { + Building(builder => { builder.UseStoveNullObjectMapper(); }).Ok(); + } + + [Fact] + public void Map_TDestination_should_throw_StoveException() + { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- + var mapper = The(); + var myObj = new MyClass2(); + + //----------------------------------------------------------------------------------------------------------- + // Act + //----------------------------------------------------------------------------------------------------------- + Action mappingAction = () => { mapper.Map(myObj); }; + + //----------------------------------------------------------------------------------------------------------- + // Assert + //----------------------------------------------------------------------------------------------------------- + mappingAction.ShouldThrow(); + } + + [Fact] + public void Map_TDestination_TSource_should_throw_StoveException() + { + //----------------------------------------------------------------------------------------------------------- + // Arrange + //----------------------------------------------------------------------------------------------------------- + var mapper = The(); + var source = new MyClass1(); + var destination = new MyClass2(); + + //----------------------------------------------------------------------------------------------------------- + // Act + //----------------------------------------------------------------------------------------------------------- + Action mappingAction = () => { mapper.Map(source, destination); }; + + //----------------------------------------------------------------------------------------------------------- + // Assert + //----------------------------------------------------------------------------------------------------------- + mappingAction.ShouldThrow(); + } + + private class MyClass1 + { + } + + private class MyClass2 + { + } + } +} diff --git a/test/Stove.Tests/Stove.Tests.csproj b/test/Stove.Tests/Stove.Tests.csproj new file mode 100644 index 0000000..702d37d --- /dev/null +++ b/test/Stove.Tests/Stove.Tests.csproj @@ -0,0 +1,34 @@ + + + + 0.0.1 + net461 + Stove.Tests + Stove.Tests + true + false + false + false + false + false + false + false + false + + + + + + + + + + + + + + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\System.Transactions.dll + + + + diff --git a/test/Stove.Tests/Stove.Tests.v3.ncrunchproject b/test/Stove.Tests/Stove.Tests.v3.ncrunchproject new file mode 100644 index 0000000..101c806 --- /dev/null +++ b/test/Stove.Tests/Stove.Tests.v3.ncrunchproject @@ -0,0 +1,8 @@ + + + + AbnormalReferenceResolution + + True + + \ No newline at end of file diff --git a/test/Stove.Tests/Stove.Tests.xproj b/test/Stove.Tests/Stove.Tests.xproj deleted file mode 100644 index 18be6dd..0000000 --- a/test/Stove.Tests/Stove.Tests.xproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - daca9bc4-be8a-4ffe-9243-74fbbc70fa5b - Stove.Tests - .\obj - .\bin\ - - - 2.0 - - - - - - \ No newline at end of file diff --git a/test/Stove.Tests/Utils/Etc/NullDisposableTests.cs b/test/Stove.Tests/Utils/Etc/NullDisposableTests.cs new file mode 100644 index 0000000..01e2832 --- /dev/null +++ b/test/Stove.Tests/Utils/Etc/NullDisposableTests.cs @@ -0,0 +1,27 @@ +using Shouldly; + +using Stove.Utils.Etc; + +using Xunit; + +namespace Stove.Tests.Utils.Etc +{ + public class NullDisposableTests + { + [Fact] + public void should_be_instantiatable() + { + NullDisposable instance = NullDisposable.Instance; + + instance.ShouldNotBeNull(); + } + + [Fact] + public void should_be_dispose() + { + using (NullDisposable.Instance) + { + } + } + } +} diff --git a/test/Stove.Tests/project.json b/test/Stove.Tests/project.json deleted file mode 100644 index 55c1ffa..0000000 --- a/test/Stove.Tests/project.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "0.0.1-*", - - "testRunner": "xunit", - "dependencies": { - "Autofac": "4.3.0", - "Stove.TestBase": "0.0.1-*" - }, - - "frameworks" : { - "net461" : { - - } - } -}