This repository has been archived by the owner on Dec 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37b8c95
commit 5463071
Showing
1 changed file
with
90 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using ActiveDirectoryQuerier.PowerShell; | ||
// ReSharper disable ConvertConstructorToMemberInitializers | ||
|
||
namespace ActiveDirectoryQuerier.Tests; | ||
|
||
/// <remarks> | ||
/// Since ActiveDirectoryInfo executes Active Directory commands, and it's not guaranteed that the tests will be | ||
/// executed on an Active Directory domain, the output will vary in location (StdOut or StdErr) and content. Therefore, | ||
/// it's more important to test that something is returned rather than the actual contents of the output. | ||
/// </remarks> | ||
public class ActiveDirectoryInfoTests | ||
{ | ||
private readonly ActiveDirectoryInfo _adInfo = new(); | ||
|
||
[Fact] | ||
public async Task GetADUsers_ReturnsExpectedOutput() | ||
{ | ||
// Act | ||
PSOutput result = await _adInfo.AvailableOptions["Get user on domain"](); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
|
||
if (result.HadErrors) | ||
{ | ||
Assert.True(result.StdErr.Count > 0); | ||
} | ||
else | ||
{ | ||
Assert.True(result.StdOut.Count > 0); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task GetADComputers_ReturnsExpectedOutput() | ||
{ | ||
// Act | ||
PSOutput result = await _adInfo.AvailableOptions["Get computers on domain"](); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
|
||
if (result.HadErrors) | ||
{ | ||
Assert.True(result.StdErr.Count > 0); | ||
} | ||
else | ||
{ | ||
Assert.True(result.StdOut.Count > 0); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task GetADIPv4Addresses_ReturnsExpectedOutput() | ||
{ | ||
// Act | ||
PSOutput result = await _adInfo.AvailableOptions["Get IPv4 of each system on domain"](); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
|
||
if (result.HadErrors) | ||
{ | ||
Assert.True(result.StdErr.Count > 0); | ||
} | ||
else | ||
{ | ||
Assert.True(result.StdOut.Count > 0); | ||
} | ||
} | ||
|
||
[Fact] | ||
public async Task GetADIPv6Addresses_ReturnsExpectedOutput() | ||
{ | ||
// Act | ||
PSOutput result = await _adInfo.AvailableOptions["Get IPv6 of each system on domain"](); | ||
|
||
// Assert | ||
Assert.NotNull(result); | ||
|
||
if (result.HadErrors) | ||
{ | ||
Assert.True(result.StdErr.Count > 0); | ||
} | ||
else | ||
{ | ||
Assert.True(result.StdOut.Count > 0); | ||
} | ||
} | ||
} |