Fix tests

pull/352/head
NextTurn 2018-12-08 00:00:00 +08:00
parent 6ace0c3ccd
commit afadf8f2b2
No known key found for this signature in database
GPG Key ID: 17A0D50ADDE1A0C4
4 changed files with 9 additions and 7 deletions

View File

@ -45,7 +45,7 @@ namespace winswTests.Configuration
private ServiceDescriptor doLoad(string exampleName) { private ServiceDescriptor doLoad(string exampleName) {
var dir = Directory.GetCurrentDirectory(); var dir = Directory.GetCurrentDirectory();
string path = dir + "\\..\\..\\..\\..\\..\\examples\\sample-" + exampleName + ".xml"; string path = Path.GetFullPath(dir + "\\..\\..\\..\\..\\..\\..\\examples\\sample-" + exampleName + ".xml");
if (!File.Exists(path)) if (!File.Exists(path))
{ {
throw new FileNotFoundException("Cannot find the XML file " + path, path); throw new FileNotFoundException("Cannot find the XML file " + path, path);

View File

@ -1,9 +1,9 @@
<NUnitProject> <NUnitProject>
<Settings activeconfig="Release" /> <Settings activeconfig="Release" />
<Config name="Debug"> <Config name="Debug">
<assembly path="bin\Debug\winswTests.dll" /> <assembly path="bin\Debug\net40\winswTests.dll" />
</Config> </Config>
<Config name="Release"> <Config name="Release">
<assembly path="bin\Release\winswTests.dll" /> <assembly path="bin\Release\net40\winswTests.dll" />
</Config> </Config>
</NUnitProject> </NUnitProject>

View File

@ -18,6 +18,8 @@ namespace winswTests.Util
[Test] [Test]
public void ShouldPropagateVariablesInUppercase() public void ShouldPropagateVariablesInUppercase()
{ {
Environment.SetEnvironmentVariable("TEST_KEY", "TEST_VALUE");
var tmpDir = FilesystemTestHelper.CreateTmpDirectory(); var tmpDir = FilesystemTestHelper.CreateTmpDirectory();
String envFile = Path.Combine(tmpDir, "env.properties"); String envFile = Path.Combine(tmpDir, "env.properties");
String scriptFile = Path.Combine(tmpDir, "printenv.bat"); String scriptFile = Path.Combine(tmpDir, "printenv.bat");
@ -40,12 +42,10 @@ namespace winswTests.Util
String[] keys = new String[envVars.Count]; String[] keys = new String[envVars.Count];
envVars.Keys.CopyTo(keys, 0); envVars.Keys.CopyTo(keys, 0);
String availableVars = "[" + String.Join(",", keys) + "]"; String availableVars = "[" + String.Join(",", keys) + "]";
Assert.That(envVars.ContainsKey("PROCESSOR_ARCHITECTURE"), "No PROCESSOR_ARCHITECTURE in the injected vars: " + availableVars); Assert.That(envVars.ContainsKey("TEST_KEY"), "No TEST_KEY in the injected vars: " + availableVars);
Assert.That(envVars.ContainsKey("COMPUTERNAME"), "No COMPUTERNAME in the injected vars: " + availableVars);
Assert.That(envVars.ContainsKey("PATHEXT"), "No PATHEXT in the injected vars: " + availableVars);
// And just ensure that the parsing logic is case-sensitive // And just ensure that the parsing logic is case-sensitive
Assert.That(!envVars.ContainsKey("computername"), "Test error: the environment parsing logic is case-insensitive"); Assert.That(!envVars.ContainsKey("test_key"), "Test error: the environment parsing logic is case-insensitive");
} }

View File

@ -8,8 +8,10 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="8.0.5.0" /> <PackageReference Include="JetBrains.Annotations" Version="8.0.5.0" />
<PackageReference Include="log4net" Version="2.0.8" /> <PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" /> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
<PackageReference Include="NUnit" Version="2.6.4" /> <PackageReference Include="NUnit" Version="2.6.4" />
<PackageReference Include="NUnitTestAdapter" Version="2.2.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>