Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix test condition
  • Loading branch information
ericstj committed May 2, 2023
commit f05ef3e6c0c2ca18e8f482a2a2e07f123e1208d4
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void DefaultsToOffOutsideOfService()
Assert.IsType<ConsoleLifetime>(lifetime);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsPrivilegedProcess))]
[ConditionalFact(typeof(AdminHelpers), nameof(AdminHelpers.IsProcessElevated))]
public void CanCreateService()
{
using var serviceTester = WindowsServiceTester.Create(() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.Hosting
{
public class WindowsServiceLifetimeTests
{
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsPrivilegedProcess))]
[ConditionalFact(typeof(AdminHelpers), nameof(AdminHelpers.IsProcessElevated))]
public void ServiceStops()
{
using var serviceTester = WindowsServiceTester.Create(async () =>
Expand Down Expand Up @@ -60,7 +60,7 @@ public void ServiceStops()
Assert.Equal(0, status.win32ExitCode);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsPrivilegedProcess))]
[ConditionalFact(typeof(AdminHelpers), nameof(AdminHelpers.IsProcessElevated))]
[SkipOnTargetFramework(TargetFrameworkMonikers.NetFramework, ".NET Framework is missing the fix from https://github.com/dotnet/corefx/commit/3e68d791066ad0fdc6e0b81828afbd9df00dd7f8")]
public void ExceptionOnStartIsPropagated()
{
Expand All @@ -81,7 +81,7 @@ await Assert.ThrowsAsync<Exception>(async () =>
Assert.Equal(Interop.Errors.ERROR_EXCEPTION_IN_SERVICE, status.win32ExitCode);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsPrivilegedProcess))]
[ConditionalFact(typeof(AdminHelpers), nameof(AdminHelpers.IsProcessElevated))]
public void ExceptionOnStopIsPropagated()
{
using var serviceTester = WindowsServiceTester.Create(async () =>
Expand All @@ -103,7 +103,7 @@ await Assert.ThrowsAsync<Exception>( async () =>
Assert.Equal(Interop.Errors.ERROR_PROCESS_ABORTED, status.win32ExitCode);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsPrivilegedProcess))]
[ConditionalFact(typeof(AdminHelpers), nameof(AdminHelpers.IsProcessElevated))]
public void CancelStopAsync()
{
using var serviceTester = WindowsServiceTester.Create(async () =>
Expand All @@ -126,7 +126,7 @@ public void CancelStopAsync()
Assert.Equal(Interop.Errors.ERROR_PROCESS_ABORTED, status.win32ExitCode);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsPrivilegedProcess))]
[ConditionalFact(typeof(AdminHelpers), nameof(AdminHelpers.IsProcessElevated))]
public void ServiceCanStopItself()
{
using (var serviceTester = WindowsServiceTester.Create(async () =>
Expand Down Expand Up @@ -182,7 +182,7 @@ lifetime stopped
""", logText);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsPrivilegedProcess))]
[ConditionalFact(typeof(AdminHelpers), nameof(AdminHelpers.IsProcessElevated))]
public void ServiceSequenceIsCorrect()
{
using (var serviceTester = WindowsServiceTester.Create(() =>
Expand Down