From 98aa74a8d6bae38f359341120bba4ceba89850d5 Mon Sep 17 00:00:00 2001 From: checkymander Date: Fri, 16 Feb 2024 11:31:11 -0500 Subject: [PATCH] update TaskingTests to be more reliable --- .../Tests/Agent.Tests/AgentTests/TaskingTests.cs | 12 ++++++++---- .../Tests/Agent.Tests/TestClasses/TestTaskManager.cs | 5 +++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/AgentTests/TaskingTests.cs b/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/AgentTests/TaskingTests.cs index 01aaa8667..ecc4800bf 100644 --- a/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/AgentTests/TaskingTests.cs +++ b/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/AgentTests/TaskingTests.cs @@ -30,9 +30,11 @@ public async Task TestGetTaskingSingle() TestProfile prof = (TestProfile)_profile.First(); Task.Run(() => _agent.Start()); - prof.taskingSent.WaitOne(1000); + ((TestTaskManager)_taskManager).WaitForNumberOfJobs(1); + //prof.taskingSent.WaitOne(1000); _profile.First().StopBeacon(); - Assert.IsTrue(((TestTaskManager)_taskManager).jobs.Count > 0); + Console.WriteLine(((TestTaskManager)_taskManager).jobs.Count); + Assert.IsTrue(((TestTaskManager)_taskManager).jobs.Count == 1); } [TestMethod] public async Task TestGetTaskingMultiple() @@ -79,9 +81,11 @@ public async Task TestGetTaskingMultiple() TestProfile prof = (TestProfile)_profile.First(); Task.Run(_agent.Start); - prof.taskingSent.WaitOne(50); + ((TestTaskManager)_taskManager).WaitForNumberOfJobs(3); + //prof.taskingSent.WaitOne(1000); _profile.First().StopBeacon(); - Assert.IsTrue(((TestTaskManager)_taskManager).jobs.Count > 1); + Console.WriteLine(((TestTaskManager)_taskManager).jobs.Count); + Assert.IsTrue(((TestTaskManager)_taskManager).jobs.Count == 3); } [TestMethod] public async Task TestGetTaskingNoTasks() { diff --git a/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/TestClasses/TestTaskManager.cs b/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/TestClasses/TestTaskManager.cs index 781a203c7..daefdcd06 100644 --- a/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/TestClasses/TestTaskManager.cs +++ b/Payload_Type/athena/athena/agent_code/Tests/Agent.Tests/TestClasses/TestTaskManager.cs @@ -35,5 +35,10 @@ public async Task StartTaskAsync(ServerJob job) jobs.Add(job); return; } + + public void WaitForNumberOfJobs(int numberOfJobs) + { + while(jobs.Count < numberOfJobs) { } + } } }