Skip to content
This repository has been archived by the owner on Dec 21, 2024. It is now read-only.

Commit

Permalink
New tests
Browse files Browse the repository at this point in the history
  • Loading branch information
StrangeRanger committed Mar 28, 2024
1 parent 37b8c95 commit 5463071
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions ActiveDirectoryQuerier.Tests/ActiveDirectoryInfoTests.cs
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);
}
}
}

0 comments on commit 5463071

Please sign in to comment.