Windows Service

Library Kata „Windows Service“

Implement a library that makes it simple to implement Windows services.

As a user I want to install a Windows service with the following command:

The command installs the service so that it is shown in Windows under Control Panel / Services. The following Windows command should start the service after it was installed:

It can be stopped with the following Windows command:

The service should be removed from the system with the following command:

The library should be implemented so that the developer has to implement the following interface if he wants to implement a Windows service:

A class that implements this interface can be run as a Windows service by using the library. The library has to contain a class EasyService that is to be used like the following:

In this example the class MyService implements the interface IService. An instance of the class as well as the command line arguments is given to the static Run method. The method interprets the command line arguments and installs or uninstalls the service.

Variation #1

To make it possible to use the library without implementing the IService interface the Run method should have an overload where the necessary information is give as parameters:

The first three string parameters correspond to the properties Name, DisplayName and Description of the interface. OnStart and OnStop are lambda expressions of type Action. The class MyService now does not have to implement the IService interface.

Variation #2

It should be possible to run the service without installing it by the following command line:

That would make debugging the service more simple.