Skip to content

Commit

Permalink
Add WireMock.Net.Service example
Browse files Browse the repository at this point in the history
  • Loading branch information
StefH committed Mar 18, 2018
1 parent 49963df commit a4a9f2c
Show file tree
Hide file tree
Showing 14 changed files with 412 additions and 3 deletions.
7 changes: 7 additions & 0 deletions WireMock.Net Solution.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WireMock.Net.Console.Proxy.
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.StandAlone.Net461", "examples\WireMock.Net.StandAlone.Net461\WireMock.Net.StandAlone.Net461.csproj", "{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WireMock.Net.Service", "examples\Wiremock.Net.Service\WireMock.Net.Service.csproj", "{7F0B2446-0363-4720-AF46-F47F83B557DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -107,6 +109,10 @@ Global
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65}.Release|Any CPU.Build.0 = Release|Any CPU
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7F0B2446-0363-4720-AF46-F47F83B557DC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -125,6 +131,7 @@ Global
{26433A8F-BF01-4962-97EB-81BFFBB61096} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
{23A9AA3C-40FC-42AA-8A5E-05899795A1C6} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
{3C279524-DB73-4DE3-BEF1-F2B2958C9F65} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
{7F0B2446-0363-4720-AF46-F47F83B557DC} = {F0C22C47-DF71-463C-9B04-B4E0F3B8708A}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BF428BCC-C837-433B-87D2-15C7014B73E9}
Expand Down
14 changes: 14 additions & 0 deletions examples/WireMock.Net.Service/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
28 changes: 28 additions & 0 deletions examples/WireMock.Net.Service/InstallUtil.InstallLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@


The uninstall is beginning.
See the contents of the log file for the C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\Wiremock.Net.Service.exe assembly's progress.
The file is located at C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\Wiremock.Net.Service.InstallLog.

The uninstall has completed.


The uninstall is beginning.
See the contents of the log file for the C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\Wiremock.Net.Service.exe assembly's progress.
The file is located at C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\Wiremock.Net.Service.InstallLog.

The uninstall has completed.


The uninstall is beginning.
See the contents of the log file for the C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\Wiremock.Net.Service.exe assembly's progress.
The file is located at C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\Wiremock.Net.Service.InstallLog.

The uninstall has completed.


The uninstall is beginning.
See the contents of the log file for the C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\WireMock.Net.Service.exe assembly's progress.
The file is located at C:\Users\azureuser\Documents\Github\WireMock.Net\examples\Wiremock.Net.Service\bin\debug\WireMock.Net.Service.InstallLog.

The uninstall has completed.
59 changes: 59 additions & 0 deletions examples/WireMock.Net.Service/Installer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions examples/WireMock.Net.Service/Installer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Threading.Tasks;

namespace Wiremock.Net.Service
{
[RunInstaller(true)]
public partial class Installer : System.Configuration.Install.Installer
{
public Installer()
{
InitializeComponent();
}
}
}
74 changes: 74 additions & 0 deletions examples/WireMock.Net.Service/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.ServiceProcess;
using WireMock.Logging;
using WireMock.Net.StandAlone;
using WireMock.Server;
using WireMock.Settings;

namespace Wiremock.Net.Service
{
public static class Program
{
#region Nested classes to support running as service
public const string ServiceName = "Wiremock.Net.Service";

public class Service : ServiceBase
{
public Service()
{
ServiceName = Program.ServiceName;
}

protected override void OnStart(string[] args)
{
Start();
}

protected override void OnStop()
{
Program.Stop();
}
}
#endregion

private static FluentMockServer _server;

static void Main(string[] args)
{
// running as service
if (!Environment.UserInteractive)
{
using (var service = new Service())
{
ServiceBase.Run(service);
}
}
else
{
// running as console app
Start();

Console.WriteLine("Press any key to stop...");
Console.ReadKey(true);

Stop();
}
}

private static void Start()
{
_server = StandAloneApp.Start(new FluentMockServerSettings
{
Urls = new[] { "http://*:9091/" },
StartAdminInterface = true,
ReadStaticMappings = true,
Logger = new WireMockConsoleLogger()
});
}

private static void Stop()
{
_server.Stop();
}
}
}
35 changes: 35 additions & 0 deletions examples/WireMock.Net.Service/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
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: AssemblyTitle("Wiremock.Net.Service")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wiremock.Net.Service")]
[assembly: AssemblyCopyright("Copyright © Stef Heyenrath 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// 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("7f0b2446-0363-4720-af46-f47f83b557dc")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
11 changes: 11 additions & 0 deletions examples/WireMock.Net.Service/Service-Install.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@echo off
call uninstall.bat

SET mypath=%~dp0
SET targetpath=C:\Services\WireMock.Net.Service\

mkdir "%targetpath%"
xcopy "%mypath%*" "%targetpath%*"

C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe "%targetpath%WireMock.Net.Service.exe"
net start "WireMock.Net.Service"
3 changes: 3 additions & 0 deletions examples/WireMock.Net.Service/Service-Start.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

net start "WireMock.Net.Service"
3 changes: 3 additions & 0 deletions examples/WireMock.Net.Service/Service-Stop.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

net stop "WireMock.Net.Service"
9 changes: 9 additions & 0 deletions examples/WireMock.Net.Service/Service-Uninstall.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@echo off
SET mypath=%~dp0
SET targetpath=C:\Services\WireMock.Net.Service\

net stop "WireMock.Net.Service"
C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe /u "%mypath%WireMock.Net.Service.exe"
sc delete "WireMock.Net.Service"

rmdir /S /Q "%targetpath%"
Loading

0 comments on commit a4a9f2c

Please sign in to comment.