From 56557f85c2cc9d0b514080cdad5eb67c6a59682b Mon Sep 17 00:00:00 2001 From: rvazarkar Date: Thu, 15 Aug 2024 15:30:12 -0400 Subject: [PATCH] chore: fix tests --- test/unit/ComputerSessionProcessorTest.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/unit/ComputerSessionProcessorTest.cs b/test/unit/ComputerSessionProcessorTest.cs index b8b3406f..816c7498 100644 --- a/test/unit/ComputerSessionProcessorTest.cs +++ b/test/unit/ComputerSessionProcessorTest.cs @@ -252,14 +252,26 @@ public async Task ComputerSessionProcessor_TestTimeout() { Assert.Single(receivedStatus); var status = receivedStatus[0]; Assert.Equal("Timeout", status.Status); + } + + [Fact] + public async Task ComputerSessionProcessor_TestTimeoutPrivileged() { + var nativeMethods = new Mock(); + nativeMethods.Setup(x => x.NetWkstaUserEnum(It.IsAny())).Callback(() => { + Thread.Sleep(200); + }).Returns(Array.Empty()); + var processor = new ComputerSessionProcessor(new MockLdapUtils(),"", nativeMethods.Object); + var receivedStatus = new List(); + var machineDomainSid = $"{Consts.MockDomainSid}-1000"; + processor.ComputerStatusEvent += async status => { + receivedStatus.Add(status); + }; - receivedStatus.Clear(); - - results = await processor.ReadUserSessionsPrivileged("primary.testlab.local", machineDomainSid, "testlab.local", + var results = await processor.ReadUserSessionsPrivileged("primary.testlab.local", machineDomainSid, "testlab.local", TimeSpan.FromMilliseconds(1)); Assert.Empty(results.Results); Assert.Single(receivedStatus); - status = receivedStatus[0]; + var status = receivedStatus[0]; Assert.Equal("Timeout", status.Status); } }