-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #620 from WildGums/feature/nullable-fix
Fix NullReferenceException when the native enumerator returns null
- Loading branch information
Showing
14 changed files
with
96 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
...rc.SystemInfo.Tests/PublicApiFacts.Orc_SystemInfo_HasNoBreakingChanges_Async.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Orc.SystemInfo.Tests/Wmi/WindowsManagementObjectEnumeratorFacts.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
namespace Orc.SystemInfo.Tests | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Moq; | ||
using NUnit.Framework; | ||
using Orc.SystemInfo.Win32; | ||
using Orc.SystemInfo.Wmi; | ||
|
||
public class WindowsManagementObjectEnumeratorFacts | ||
{ | ||
[Test] | ||
public async Task Returns_False_When_Enumerator_Returns_Null_Async() | ||
{ | ||
IWbemClassObject objects; | ||
uint returnedCount; | ||
|
||
var wbemClassObjectEnumeratorMock = new Mock<IWbemClassObjectEnumerator>(); | ||
|
||
wbemClassObjectEnumeratorMock.Setup(x => x.Next(It.IsAny<int>(), It.IsAny<uint>(), out objects, out returnedCount)) | ||
.Returns((int to, uint c, out IWbemClassObject o, out uint rc) => | ||
{ | ||
o = null; | ||
rc = 0; | ||
return new HResult(0); | ||
}); | ||
|
||
using var enumerator = new WindowsManagementObjectEnumerator(wbemClassObjectEnumeratorMock.Object); | ||
|
||
var moveNextResult = enumerator.MoveNext(); | ||
|
||
Assert.That(moveNextResult, Is.False); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 1 addition & 2 deletions
3
src/Orc.SystemInfo/Win32/Wbem/Extensions/IWbemClassObjectEnumeratorExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters