Tests: Add ExamplesTests and fix the issues in the code

pull/170/head
Oleg Nenashev 2016-12-23 22:30:15 +01:00
parent 4db3266125
commit c0d2d0b6e3
5 changed files with 53 additions and 11 deletions

View File

@ -18,12 +18,12 @@
--> -->
<!-- <!--
- This is a sample configuration of the Windows Service Wrapper. This is a sample configuration of the Windows Service Wrapper.
- This configuration file should be placed near the WinSW executable, the name should be the same. This configuration file should be placed near the WinSW executable, the name should be the same.
- E.g. for myapp.exe the configuration file name should be myapp.xml E.g. for myapp.exe the configuration file name should be myapp.xml
-
- You can find more information about the parameters here: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md You can find more information about the parameters here: https://github.com/kohsuke/winsw/blob/master/doc/xmlConfigFile.md
--> -->
<configuration> <configuration>
<!-- <!--
@ -148,9 +148,9 @@ SECTION: Executable management
Additional arguments, which should be passed to the stop executable during termination. Additional arguments, which should be passed to the stop executable during termination.
This OPTION also enables termination of the executable via stop executable This OPTION also enables termination of the executable via stop executable
--> -->
<!--<stoparguments>--stop true</stoparguments>-->
<!-- <!--
<stoparguments>-stop true</stoparguments>-->
-->
<!-- <!--
SECTION: Service management SECTION: Service management
--> -->
@ -205,7 +205,9 @@ SECTION:Logging
Sets a custom logging directory for all logs being produced by the service wrapper Sets a custom logging directory for all logs being produced by the service wrapper
Default value: Directory, which contains the executor Default value: Directory, which contains the executor
--> -->
<logpath></logpath> <!--
<logpath>%BASE%\logs</logpath>
-->
<!-- <!--
OPTION: log OPTION: log

View File

@ -33,7 +33,7 @@ namespace winsw.Configuration
// Installation // Installation
public bool AllowServiceAcountLogonRight { get { return false; } } public bool AllowServiceAcountLogonRight { get { return false; } }
public string ServiceAccountPassword { get { return null; } } public string ServiceAccountPassword { get { return null; } }
public string ServiceAccountUser { get { return null; } } public string ServiceAccountUser { get { return "NULL\\NULL"; } }
public List<winsw.Native.SC_ACTION> FailureActions { get { return new List<winsw.Native.SC_ACTION>(); } } public List<winsw.Native.SC_ACTION> FailureActions { get { return new List<winsw.Native.SC_ACTION>(); } }
public TimeSpan ResetFailureAfter { get { return TimeSpan.FromDays(1); } } public TimeSpan ResetFailureAfter { get { return TimeSpan.FromDays(1); } }

View File

@ -5,7 +5,7 @@ using System.Xml;
using WMI; using WMI;
namespace winsw.Configuration namespace winsw.Configuration
{ {
interface IWinSWConfiguration public interface IWinSWConfiguration
{ {
//TODO: Document the parameters && refactor //TODO: Document the parameters && refactor

View File

@ -0,0 +1,39 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using winsw;
using winswTests.Util;
namespace winswTests.Configuration
{
/// <summary>
/// Tests example configuration files.
/// The test uses a relative path to example files, which is based on the current project structure.
/// </summary>
[TestFixture]
class ExamplesTest
{
[Test]
public void allOptionsConfigShouldDeclareDefaults()
{
ServiceDescriptor d = doLoad("allOptions");
ServiceDescriptorAssert.AssertAllOptionalPropertiesAreDefault(d);
}
private ServiceDescriptor doLoad(string exampleName) {
var dir = Directory.GetCurrentDirectory();
string path = dir + "\\..\\..\\..\\..\\..\\examples\\" + exampleName + ".xml";
if (!File.Exists(path))
{
throw new FileNotFoundException("Cannot find the XML file " + path, path);
}
XmlDocument dom = new XmlDocument();
dom.Load(path);
return new ServiceDescriptor(dom);
}
}
}

View File

@ -55,6 +55,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Configuration\ExamplesTest.cs" />
<Compile Include="Extensions\ExtensionTestBase.cs" /> <Compile Include="Extensions\ExtensionTestBase.cs" />
<Compile Include="Extensions\RunawayProcessKillerTest.cs" /> <Compile Include="Extensions\RunawayProcessKillerTest.cs" />
<Compile Include="Extensions\SharedDirectoryMapperTest.cs" /> <Compile Include="Extensions\SharedDirectoryMapperTest.cs" />