mirror of https://github.com/winsw/winsw
Issue #159 - reproduce issue in tests
parent
806c945d65
commit
fca428d351
|
@ -253,12 +253,44 @@ namespace winswTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void VerifyWaitHint()
|
public void VerifyWaitHint_FullXML()
|
||||||
{
|
{
|
||||||
var sd = ConfigXmlBuilder.create().WithTag("waithint", "20 min").ToServiceDescriptor(true);
|
var sd = ConfigXmlBuilder.create()
|
||||||
|
.WithTag("waithint", "20 min")
|
||||||
|
.ToServiceDescriptor(true);
|
||||||
Assert.That(sd.WaitHint, Is.EqualTo(TimeSpan.FromMinutes(20)));
|
Assert.That(sd.WaitHint, Is.EqualTo(TimeSpan.FromMinutes(20)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Test for https://github.com/kohsuke/winsw/issues/159
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void VerifyWaitHint_XMLWithoutVersion()
|
||||||
|
{
|
||||||
|
var sd = ConfigXmlBuilder.create(printXMLVersion: false)
|
||||||
|
.WithTag("waithint", "21 min")
|
||||||
|
.ToServiceDescriptor(true);
|
||||||
|
Assert.That(sd.WaitHint, Is.EqualTo(TimeSpan.FromMinutes(21)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void VerifyWaitHint_XMLWithoutComment()
|
||||||
|
{
|
||||||
|
var sd = ConfigXmlBuilder.create(xmlComment: null)
|
||||||
|
.WithTag("waithint", "22 min")
|
||||||
|
.ToServiceDescriptor(true);
|
||||||
|
Assert.That(sd.WaitHint, Is.EqualTo(TimeSpan.FromMinutes(22)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void VerifyWaitHint_XMLWithoutVersionAndComment()
|
||||||
|
{
|
||||||
|
var sd = ConfigXmlBuilder.create(xmlComment: null, printXMLVersion: false)
|
||||||
|
.WithTag("waithint", "23 min")
|
||||||
|
.ToServiceDescriptor(true);
|
||||||
|
Assert.That(sd.WaitHint, Is.EqualTo(TimeSpan.FromMinutes(23)));
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void VerifySleepTime()
|
public void VerifySleepTime()
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,28 +14,45 @@ namespace winswTests.Util
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
public string Executable { get; set; }
|
public string Executable { get; set; }
|
||||||
|
public bool PrintXMLVersion { get; set; }
|
||||||
|
public string XMLComment { get; set; }
|
||||||
|
|
||||||
private List<String> configEntries;
|
private List<String> configEntries;
|
||||||
|
|
||||||
|
// TODO: Switch to the initializer?
|
||||||
private ConfigXmlBuilder()
|
private ConfigXmlBuilder()
|
||||||
{
|
{
|
||||||
configEntries = new List<string>();
|
configEntries = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConfigXmlBuilder create(string id = null, string name = null,
|
public static ConfigXmlBuilder create(string id = null, string name = null,
|
||||||
string description = null, string executable = null)
|
string description = null, string executable = null, bool printXMLVersion = true,
|
||||||
|
string xmlComment = "")
|
||||||
{
|
{
|
||||||
var config = new ConfigXmlBuilder();
|
var config = new ConfigXmlBuilder();
|
||||||
config.Id = id ?? "myapp";
|
config.Id = id ?? "myapp";
|
||||||
config.Name = name ?? "MyApp Service";
|
config.Name = name ?? "MyApp Service";
|
||||||
config.Description = description ?? "MyApp Service (powered by WinSW)";
|
config.Description = description ?? "MyApp Service (powered by WinSW)";
|
||||||
config.Executable = executable ?? "%BASE%\\myExecutable.exe";
|
config.Executable = executable ?? "%BASE%\\myExecutable.exe";
|
||||||
|
config.PrintXMLVersion = printXMLVersion;
|
||||||
|
config.XMLComment = (xmlComment != null && xmlComment.Length == 0)
|
||||||
|
? "Just a sample configuration file generated by the test suite"
|
||||||
|
: xmlComment;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ToXMLString(bool dumpConfig = false)
|
public string ToXMLString(bool dumpConfig = false)
|
||||||
{
|
{
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
|
if (PrintXMLVersion)
|
||||||
|
{
|
||||||
|
// TODO: The encoding is generally wrong
|
||||||
|
str.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
|
||||||
|
}
|
||||||
|
if (XMLComment != null)
|
||||||
|
{
|
||||||
|
str.AppendFormat("<!--{0}-->\n", XMLComment);
|
||||||
|
}
|
||||||
str.Append("<service>\n");
|
str.Append("<service>\n");
|
||||||
str.AppendFormat(" <id>{0}</id>\n", Id);
|
str.AppendFormat(" <id>{0}</id>\n", Id);
|
||||||
str.AppendFormat(" <name>{0}</name>\n", Name);
|
str.AppendFormat(" <name>{0}</name>\n", Name);
|
||||||
|
|
Loading…
Reference in New Issue