Dotnet 20 preview final (#41)

* 1.0.2.3-preview2-final-01

* fixes for AspNetCoreSelfHost (Task...)

* enable all target frameworks again
This commit is contained in:
Stef Heyenrath
2017-08-11 13:27:18 +02:00
committed by GitHub
parent 5c5d408abe
commit 8d072e8b47
8 changed files with 84 additions and 97 deletions

View File

@@ -14,9 +14,18 @@ A C# .NET version based on [mock4net](https://github.com/alexvictoor/mock4net) w
### Frameworks ### Frameworks
The following frameworks are supported: The following frameworks are supported:
- net 4.5
- net 4.5.2 and up - net 4.5.2 and up
- net 4.6 and up
- netstandard 1.3 - netstandard 1.3
- netstandard 2.0
## Build info
To build you need:
- Microsoft .NET Framework 4.5.2 Developer Pack (https://www.microsoft.com/en-us/download/details.aspx?id=42637)
- Microsoft .NET Framework 4.6 Targeting Pack (https://www.microsoft.com/en-us/download/confirmation.aspx?id=48136)
- Microsoft .NET Framework 4.6.2 Developer Pack (https://www.microsoft.com/en-us/download/confirmation.aspx?id=53321)
* .NET Core 2.0 Preview 2 (https://www.microsoft.com/net/core/preview#windowscmd)
## Stubbing ## Stubbing
A core feature of WireMock.Net is the ability to return canned/predefined HTTP responses for requests matching criteria, see [Wiki : Stubbing](https://github.com/StefH/WireMock.Net/wiki/Stubbing). A core feature of WireMock.Net is the ability to return canned/predefined HTTP responses for requests matching criteria, see [Wiki : Stubbing](https://github.com/StefH/WireMock.Net/wiki/Stubbing).

View File

@@ -9,8 +9,8 @@ init:
- ps: $Env:LABEL = "CI" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") - ps: $Env:LABEL = "CI" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0")
install: install:
- ps: Start-FileDownload 'https://download.microsoft.com/download/8/F/9/8F9659B9-E628-4D1A-B6BF-C3004C8C954B/dotnet-1.1.1-sdk-win-x64.exe' - ps: Start-FileDownload 'https://download.microsoft.com/download/6/1/B/61B3E81F-5509-48D2-BB4F-5189E23CD29A/dotnet-sdk-2.0.0-preview2-006497-win-x64.exe'
- cmd: dotnet-1.1.1-sdk-win-x64.exe /quiet - cmd: dotnet-sdk-2.0.0-preview2-006497-win-x64.exe /quiet
- ps: $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "true" - ps: $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = "true"
environment: environment:
@@ -20,7 +20,6 @@ environment:
before_build: before_build:
- dotnet restore .\src\WireMock.Net\WireMock.Net.csproj - dotnet restore .\src\WireMock.Net\WireMock.Net.csproj
- dotnet restore .\src\WireMock.Net.Client\WireMock.Net.Client.csproj
- dotnet restore .\src\WireMock.Net.Standalone\WireMock.Net.Standalone.csproj - dotnet restore .\src\WireMock.Net.Standalone\WireMock.Net.Standalone.csproj
- nuget restore .\examples\WireMock.Net.ConsoleApplication\WireMock.Net.ConsoleApplication.csproj -PackagesDirectory packages - nuget restore .\examples\WireMock.Net.ConsoleApplication\WireMock.Net.ConsoleApplication.csproj -PackagesDirectory packages
@@ -28,13 +27,13 @@ build_script:
# build WireMock.Net # build WireMock.Net
- dotnet build .\src\WireMock.Net\WireMock.Net.csproj -c %CONFIGURATION% - dotnet build .\src\WireMock.Net\WireMock.Net.csproj -c %CONFIGURATION%
# build WireMock.Net.Standalone
- dotnet build .\src\WireMock.Net.Standalone\WireMock.Net.Standalone.csproj -c %CONFIGURATION%
# restore and build WireMock.Net.Tests # restore and build WireMock.Net.Tests
- dotnet restore .\test\WireMock.Net.Tests\WireMock.Net.Tests.csproj - dotnet restore .\test\WireMock.Net.Tests\WireMock.Net.Tests.csproj
- dotnet build .\test\WireMock.Net.Tests\WireMock.Net.Tests.csproj -c %CONFIGURATION% - dotnet build .\test\WireMock.Net.Tests\WireMock.Net.Tests.csproj -c %CONFIGURATION%
# build WireMock.Net.Standalone
- dotnet build .\src\WireMock.Net.Standalone\WireMock.Net.Standalone.csproj -c %CONFIGURATION%
test_script: test_script:
- nuget.exe install OpenCover -ExcludeVersion - nuget.exe install OpenCover -ExcludeVersion
- nuget.exe install coveralls.net -ExcludeVersion - nuget.exe install coveralls.net -ExcludeVersion

View File

@@ -1,40 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<Description>Lightweight StandAlone Http Mocking Server for .Net.</Description> <Description>Lightweight StandAlone Http Mocking Server for .Net.</Description>
<AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle> <AssemblyTitle>WireMock.Net.StandAlone</AssemblyTitle>
<Version>1.0.2.1</Version> <Version>1.0.2.4-preview-01</Version>
<Authors>Stef Heyenrath</Authors> <Authors>Stef Heyenrath</Authors>
<TargetFrameworks>net45;net452;net46;netstandard1.3</TargetFrameworks> <TargetFrameworks>net452;net46;netstandard1.3;netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <!-- <TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks> -->
<AssemblyName>WireMock.Net.StandAlone</AssemblyName> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageId>WireMock.Net.StandAlone</PackageId> <AssemblyName>WireMock.Net.StandAlone</AssemblyName>
<PackageTags>tdd;mock;http;wiremock;test;server;unittest</PackageTags> <PackageId>WireMock.Net.StandAlone</PackageId>
<PackageReleaseNotes></PackageReleaseNotes> <PackageTags>tdd;mock;http;wiremock;test;server;unittest</PackageTags>
<PackageIconUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/WireMock.Net-Logo.png</PackageIconUrl> <PackageReleaseNotes></PackageReleaseNotes>
<PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl> <PackageIconUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/WireMock.Net-Logo.png</PackageIconUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/LICENSE</PackageLicenseUrl> <PackageProjectUrl>https://github.com/WireMock-Net/WireMock.Net</PackageProjectUrl>
<RepositoryType>git</RepositoryType> <PackageLicenseUrl>https://raw.githubusercontent.com/WireMock-Net/WireMock.Net/master/LICENSE</PackageLicenseUrl>
<RepositoryUrl>https://github.com/WireMock-Net/WireMock.Net</RepositoryUrl> <RepositoryType>git</RepositoryType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <RepositoryUrl>https://github.com/WireMock-Net/WireMock.Net</RepositoryUrl>
<DebugType>full</DebugType> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon> <DebugType>full</DebugType>
<RootNamespace>WireMock.Net.StandAlone</RootNamespace> <ApplicationIcon>../../WireMock.Net-Logo.ico</ApplicationIcon>
</PropertyGroup> <RootNamespace>WireMock.Net.StandAlone</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<DefineConstants>NETSTANDARD</DefineConstants> <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' or '$(TargetFramework)' == 'netstandard2.0' ">
</PropertyGroup> <DefineConstants>NETSTANDARD</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="10.4.0"> <ItemGroup>
<PrivateAssets>All</PrivateAssets> <PackageReference Include="JetBrains.Annotations" Version="10.4.0">
</PackageReference> <PrivateAssets>All</PrivateAssets>
<PackageReference Include="CommandLineArgumentsParser" Version="3.0.11" /> </PackageReference>
</ItemGroup> <PackageReference Include="CommandLineArgumentsParser" Version="3.0.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WireMock.Net\WireMock.Net.csproj" /> <ItemGroup>
</ItemGroup> <ProjectReference Include="..\WireMock.Net\WireMock.Net.csproj" />
</ItemGroup>
</Project> </Project>

View File

@@ -45,23 +45,28 @@ namespace WireMock.Owin
public Task StartAsync() public Task StartAsync()
{ {
return Task.Run(() => IWebHost host = new WebHostBuilder()
{ // .ConfigureLogging(factory => factory.AddConsole(LogLevel.None))
var host = new WebHostBuilder()
.ConfigureLogging(factory => factory.AddConsole(LogLevel.None))
.Configure(appBuilder => .Configure(appBuilder =>
{ {
// appBuilder.UseExceptionHandler(builder => )
appBuilder.UseMiddleware<WireMockMiddleware>(_options); appBuilder.UseMiddleware<WireMockMiddleware>(_options);
}) })
.UseKestrel() .UseKestrel()
.UseUrls(_uriPrefixes) .UseUrls(_uriPrefixes)
.Build(); .Build();
#if NETSTANDARD1_3
System.Console.WriteLine("WireMock.Net server using netstandard1.3");
return Task.Run(() =>
{
host.Run(_cts.Token); host.Run(_cts.Token);
IsStarted = true; IsStarted = true;
}, _cts.Token); }, _cts.Token);
#else
System.Console.WriteLine("WireMock.Net server using netstandard2.0");
IsStarted = true;
return host.RunAsync(_cts.Token);
#endif
} }
public Task StopAsync() public Task StopAsync()
@@ -73,31 +78,5 @@ namespace WireMock.Owin
return Task.FromResult(true); return Task.FromResult(true);
} }
} }
internal class Startup
{
public Startup(IHostingEnvironment env)
{
//var builder = new ConfigurationBuilder()
// .SetBasePath(env.ContentRootPath)
// .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
// .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
// .AddEnvironmentVariables();
//Configuration = builder.Build();
}
// public IConfigurationRoot Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.UseMiddleware<WireMockMiddleware>();
}
}
} }
#endif #endif

View File

@@ -15,7 +15,6 @@ namespace WireMock.Owin
{ {
private readonly WireMockMiddlewareOptions _options; private readonly WireMockMiddlewareOptions _options;
private readonly CancellationTokenSource _cts = new CancellationTokenSource(); private readonly CancellationTokenSource _cts = new CancellationTokenSource();
private Thread _internalThread;
public OwinSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes) public OwinSelfHost([NotNull] WireMockMiddlewareOptions options, [NotNull] params string[] uriPrefixes)
{ {
@@ -55,23 +54,13 @@ namespace WireMock.Owin
{ {
_cts.Cancel(); _cts.Cancel();
var tcs = new TaskCompletionSource<bool>(); return Task.FromResult(true);
var timer = new System.Timers.Timer(999);
timer.Elapsed += (sender, e) =>
{
if (_internalThread == null)
{
timer.Stop();
tcs.SetResult(true);
}
};
timer.Start();
return tcs.Task;
} }
private void StartServers() private void StartServers()
{ {
System.Console.WriteLine("WireMock.Net server using .net 4.5.x or .net 4.6.x");
Action<IAppBuilder> startup = app => Action<IAppBuilder> startup = app =>
{ {
app.Use<WireMockMiddleware>(_options); app.Use<WireMockMiddleware>(_options);
@@ -86,12 +75,16 @@ namespace WireMock.Owin
IsStarted = true; IsStarted = true;
while (!_cts.IsCancellationRequested) while (!_cts.IsCancellationRequested)
Thread.Sleep(1000); {
Thread.Sleep(30000);
}
IsStarted = false; IsStarted = false;
foreach (var server in servers) foreach (var server in servers)
{
server.Dispose(); server.Dispose();
}
} }
} }
} }

View File

@@ -3,9 +3,10 @@
<PropertyGroup> <PropertyGroup>
<Description>Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.</Description> <Description>Lightweight Http Mocking Server for .Net, inspired by WireMock from the Java landscape.</Description>
<AssemblyTitle>WireMock.Net</AssemblyTitle> <AssemblyTitle>WireMock.Net</AssemblyTitle>
<Version>1.0.2.3</Version> <Version>1.0.2.4-preview-01</Version>
<Authors>Alexandre Victoor;Stef Heyenrath</Authors> <Authors>Alexandre Victoor;Stef Heyenrath</Authors>
<TargetFrameworks>net45;net452;net46;netstandard1.3</TargetFrameworks> <TargetFrameworks>net452;net46;netstandard1.3;netstandard2.0</TargetFrameworks>
<!-- <TargetFrameworks>netstandard1.3;netstandard2.0</TargetFrameworks> -->
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>WireMock.Net</AssemblyName> <AssemblyName>WireMock.Net</AssemblyName>
<PackageId>WireMock.Net</PackageId> <PackageId>WireMock.Net</PackageId>
@@ -22,7 +23,7 @@
<RootNamespace>WireMock</RootNamespace> <RootNamespace>WireMock</RootNamespace>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' "> <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' or '$(TargetFramework)' == 'netstandard2.0'">
<DefineConstants>NETSTANDARD</DefineConstants> <DefineConstants>NETSTANDARD</DefineConstants>
</PropertyGroup> </PropertyGroup>
@@ -31,7 +32,7 @@
<PrivateAssets>All</PrivateAssets> <PrivateAssets>All</PrivateAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Handlebars.Net" Version="1.9.0" /> <PackageReference Include="Handlebars.Net" Version="1.9.0" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="10.0.1" />
<PackageReference Include="SimMetrics.Net" Version="1.0.3" /> <PackageReference Include="SimMetrics.Net" Version="1.0.3" />
<PackageReference Include="System.Net.Http" Version="4.3.2" /> <PackageReference Include="System.Net.Http" Version="4.3.2" />
<PackageReference Include="RestEase" Version="1.4.1" /> <PackageReference Include="RestEase" Version="1.4.1" />
@@ -60,4 +61,9 @@
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" /> <PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<PackageReference Include="Microsoft.AspNetCore" Version="2.0.0-preview2-final" />
<PackageReference Include="System.Xml.XPath.XmlDocument" Version="4.3.0" />
</ItemGroup>
</Project> </Project>