Skip to content

Commit

Permalink
Added error coverage to GroupProcessorTest.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
ktstrader committed Dec 6, 2024
1 parent 3694f25 commit 9dbf114
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/unit/GroupProcessorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public class GroupProcessorTest
"CN=NonExistent,CN=Users,DC=testlab,DC=local"
};

private readonly Result<string>[] _testMembershipReturnFail =
{
Result<string>.Fail()
};


private readonly ITestOutputHelper _testOutputHelper;
private GroupProcessor _baseProcessor;
Expand Down Expand Up @@ -134,5 +139,25 @@ public async Task GroupProcessor_ReadGroupMembers_ReturnsCorrectMembers()
Assert.Equal(4, results.Length);
Assert.Equal(expected, results);
}

[Fact]
public async Task GroupProcessor_ReadGroupMembers_EmptyMembers_FailRangedRetrieval()
{
var mockUtils = new Mock<MockLdapUtils>();
mockUtils.Setup(x => x.RangedRetrieval(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>())).Returns(_testMembershipReturnFail.ToAsyncEnumerable());
var processor = new GroupProcessor(mockUtils.Object);

var results = await processor
.ReadGroupMembers("CN=Administrators,CN=Builtin,DC=testlab,DC=local", Array.Empty<string>()).ToArrayAsync();
foreach (var t in results) _testOutputHelper.WriteLine(t.ToString());
Assert.Empty(results);
}

[Fact]
public void GroupProcessor_GetPrimaryGroupInfo_NullObjectID_ReturnsNull()
{
var result = GroupProcessor.GetPrimaryGroupInfo("513", null);
Assert.Null(result);
}
}
}

0 comments on commit 9dbf114

Please sign in to comment.