Add unit tests for UsesCodeSignedAssemblies()

Used in MshSnapinInfo.PSSnapInReader
This commit is contained in:
Andrew Schwartzmeyer 2015-06-12 09:26:56 -07:00
parent de2ccdb749
commit c42ba3bd56
4 changed files with 36 additions and 1 deletions

@ -1 +1 @@
Subproject commit fbfb5a555ae4fa6d465eba59fff6edc281cdd536
Subproject commit 3ca3331f4bba19ed57595c173264a267878e0b65

View file

@ -12,6 +12,7 @@ namespace PSTests
PlatformTests.TestIsLinux();
PlatformTests.TestHasCom();
PlatformTests.TestHasAmsi();
PlatformTests.TestUsesCodeSignedAssemblies();
PSTypeExtensionsTests.TestIsComObject();
@ -20,6 +21,10 @@ namespace PSTests
SecuritySupportTests.TestCloseSession();
SecuritySupportTests.TestUninitialize();
MshSnapinInfoTests mshSnapinInfoTests = new MshSnapinInfoTests();
mshSnapinInfoTests.TestReadRegistryInfo();
mshSnapinInfoTests.TestReadCoreEngineSnapIn();
Console.WriteLine("Finished running tests");
}
}

View file

@ -20,5 +20,10 @@ namespace PSTests
{
Assert.False(Platform.HasAmsi());
}
public static void TestUsesCodeSignedAssemblies()
{
Assert.False(Platform.UsesCodeSignedAssemblies());
}
}
}

View file

@ -0,0 +1,25 @@
using Xunit;
using System;
using System.Management.Automation;
namespace PSTests
{
// Not static because a test requires non-const variables
public class MshSnapinInfoTests
{
// Test that it does not throw an exception
public void TestReadRegistryInfo()
{
Version someVersion = null;
string someString = null;
PSSnapInReader.ReadRegistryInfo(out someVersion, out someString, out someString, out someString, out someString, out someVersion);
}
// PublicKeyToken is null on Linux
public void TestReadCoreEngineSnapIn()
{
PSSnapInInfo pSSnapInInfo = PSSnapInReader.ReadCoreEngineSnapIn();
Assert.Contains("PublicKeyToken=null", pSSnapInInfo.AssemblyName);
}
}
}