From 13cccf51cc79494a706a79670bfa173fbca8f051 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Thu, 11 Jun 2015 14:40:28 -0700 Subject: [PATCH] Add unit tests for HasCom() and IsComObject() Added using declartion for clarity to test_CorePsPlatform and made test function naming scheme consistent. Update monad submodule with feature query. --- scripts/Makefile | 2 +- src/monad | 2 +- src/ps_test/ps_test.cs | 6 +++++- src/ps_test/test_CorePsPlatform.cs | 10 ++++++++-- src/ps_test/test_ExtensionMethods.cs | 15 +++++++++++++++ 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/ps_test/test_ExtensionMethods.cs diff --git a/scripts/Makefile b/scripts/Makefile index e1ab4f5fe..ec910298e 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -113,7 +113,7 @@ dotnetlibs/xunit.console.exe: $(MONAD_EXT)/xunit/xunit.console.netcore.exe cp -f $^ $@ TEST_FOLDER=../src/ps_test -TEST_SRCS=$(addprefix $(TEST_FOLDER)/, test_CorePsPlatform.cs) +TEST_SRCS=$(addprefix $(TEST_FOLDER)/, test_CorePsPlatform.cs test_ExtensionMethods.cs) dotnetlibs/ps_test.dll: $(TEST_SRCS) dotnetlibs/xunit.core.dll dotnetlibs/xunit.assert.dll dotnetlibs/System.Management.Automation.dll dotnetlibs/Microsoft.PowerShell.Commands.Management.dll dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) $(CSC) -out:$@ -noconfig -nostdlib -target:library -r:dotnetlibs/System.Management.Automation.dll -r:dotnetlibs/$(ASSEMBLY_LOAD_CONTEXT_TARGET) -r:dotnetlibs/xunit.core.dll -r:dotnetlibs/xunit.assert.dll ${COREREF} $(TEST_SRCS) diff --git a/src/monad b/src/monad index d9e1a2c7b..f8a961570 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit d9e1a2c7b0dbab00c185297952cfeaa31f3c5ea5 +Subproject commit f8a9615707051ba572b0cb7705054f9ae15d6b66 diff --git a/src/ps_test/ps_test.cs b/src/ps_test/ps_test.cs index a4a718533..3a7f011f0 100644 --- a/src/ps_test/ps_test.cs +++ b/src/ps_test/ps_test.cs @@ -9,7 +9,11 @@ namespace PSTests // - Remove static keywords static void Main() { - PlatformTests.testIsLinux(); + PlatformTests.TestIsLinux(); + PlatformTests.TestHasCom(); + + PSTypeExtensionsTests.TestIsComObject(); + Console.WriteLine("Finished running tests"); } } diff --git a/src/ps_test/test_CorePsPlatform.cs b/src/ps_test/test_CorePsPlatform.cs index cc42fa245..fb3f5a093 100644 --- a/src/ps_test/test_CorePsPlatform.cs +++ b/src/ps_test/test_CorePsPlatform.cs @@ -1,13 +1,19 @@ using Xunit; using System; +using System.Management.Automation; namespace PSTests { public static class PlatformTests { - public static void testIsLinux() + public static void TestIsLinux() { - Assert.Equal(System.Management.Automation.Platform.IsLinux(), true); + Assert.True(Platform.IsLinux()); + } + + public static void TestHasCom() + { + Assert.False(Platform.HasCom()); } } } diff --git a/src/ps_test/test_ExtensionMethods.cs b/src/ps_test/test_ExtensionMethods.cs new file mode 100644 index 000000000..b7b7d82ba --- /dev/null +++ b/src/ps_test/test_ExtensionMethods.cs @@ -0,0 +1,15 @@ +using Xunit; +using System; +using System.Management.Automation; + +namespace PSTests +{ + public static class PSTypeExtensionsTests + { + public static void TestIsComObject() + { + // It just needs an arbitrary type + Assert.False(PSTypeExtensions.IsComObject(42.GetType())); + } + } +}