public void ExitStatus_ReturnsExitCodeIfProcessHasExitedButNotBeenDisposedOf() { Process dummyProcess = null; try { // Arrange dummyProcess = CreateProcess(); NodeJSProcess testSubject = CreateNodeJSProcess(dummyProcess); // Act testSubject.Kill(); dummyProcess.WaitForExit(); string result = testSubject.ExitStatus; // Assert Assert.NotEmpty(result); // Can't gaurantee what exit code will be returned on all platforms } finally { try { dummyProcess?.Kill(); } catch { // If Kill throws, process has already terminated } finally { dummyProcess?.Dispose(); } } }
public void ExitStatus_ReturnsExitCodeIfProcessHasExitedButNotBeenDisposedOf() { // Arrange Process dummyProcess = CreateNodeJSProcess(); Mock <NodeJSProcess> mockTestSubject = _mockRepository.Create <NodeJSProcess>(dummyProcess); mockTestSubject.CallBase = true; using (NodeJSProcess testSubject = mockTestSubject.Object) { // Act testSubject.Kill(); dummyProcess.WaitForExit(); string result = mockTestSubject.Object.ExitStatus; // Assert Assert.NotEmpty(result); // Can't gaurantee what exit code will be returned on all platforms } }