From c26d0cbeb0d0b8d252ffb81afbe4d29012369721 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 18 Mar 2021 16:38:34 +0100 Subject: [PATCH] cleaned up tests and integrated them with ci --- .gitignore | 3 +- Coroutine.sln | 4 +- Coroutine/ActiveCoroutine.cs | 2 +- CoroutineTests/CoroutineTests.csproj | 20 -- {Test => Example}/Example.cs | 8 +- Example/Example.csproj | 11 + Jenkinsfile | 8 +- README.md | 2 +- Test/Test.csproj | 58 ---- .../EventBasedCoroutineTests.cs | 28 +- Tests/Tests.csproj | 19 ++ .../TimeBasedCoroutineTests.cs | 297 ++++++++---------- 12 files changed, 190 insertions(+), 270 deletions(-) delete mode 100644 CoroutineTests/CoroutineTests.csproj rename {Test => Example}/Example.cs (92%) create mode 100644 Example/Example.csproj delete mode 100644 Test/Test.csproj rename {CoroutineTests => Tests}/EventBasedCoroutineTests.cs (69%) create mode 100644 Tests/Tests.csproj rename {CoroutineTests => Tests}/TimeBasedCoroutineTests.cs (55%) diff --git a/.gitignore b/.gitignore index 38f4e9e..084d825 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ bin obj packages *.user -*.nupkg \ No newline at end of file +*.nupkg +TestResults \ No newline at end of file diff --git a/Coroutine.sln b/Coroutine.sln index b8cfe5f..bbffca5 100644 --- a/Coroutine.sln +++ b/Coroutine.sln @@ -2,9 +2,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Coroutine", "Coroutine\Coroutine.csproj", "{1657964D-2503-426A-8514-D020660BEE4D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{8BE6B559-927D-47A6-8253-D7D809D337AF}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example", "Example\Example.csproj", "{8BE6B559-927D-47A6-8253-D7D809D337AF}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoroutineTests", "CoroutineTests\CoroutineTests.csproj", "{8E110BC2-38FD-404A-B5BD-02C771B0D1D5}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{8E110BC2-38FD-404A-B5BD-02C771B0D1D5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Coroutine/ActiveCoroutine.cs b/Coroutine/ActiveCoroutine.cs index 5604593..85cd45c 100644 --- a/Coroutine/ActiveCoroutine.cs +++ b/Coroutine/ActiveCoroutine.cs @@ -5,7 +5,7 @@ using System.Diagnostics; namespace Coroutine { /// /// A reference to a currently running coroutine. - /// This is returned by . + /// This is returned by . /// public class ActiveCoroutine : IComparable { diff --git a/CoroutineTests/CoroutineTests.csproj b/CoroutineTests/CoroutineTests.csproj deleted file mode 100644 index 0214345..0000000 --- a/CoroutineTests/CoroutineTests.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - netcoreapp3.1 - - false - - - - - - - - - - - - - - diff --git a/Test/Example.cs b/Example/Example.cs similarity index 92% rename from Test/Example.cs rename to Example/Example.cs index a1dc1c2..a77e1a7 100644 --- a/Test/Example.cs +++ b/Example/Example.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Threading; using Coroutine; -namespace Test { +namespace Example { internal static class Example { private static readonly Event TestEvent = new Event(); @@ -18,10 +18,10 @@ namespace Test { Console.WriteLine("Raising test event"); CoroutineHandler.RaiseEvent(TestEvent); }); - CoroutineHandler.InvokeLater(new Wait(TestEvent), () => Console.WriteLine("Test event received")); + CoroutineHandler.InvokeLater(new Wait(TestEvent), () => Console.WriteLine("Example event received")); - CoroutineHandler.InvokeLater(new Wait(TestEvent), () => Console.WriteLine("I am invoked after 'Test event received'"), priority: -5); - CoroutineHandler.InvokeLater(new Wait(TestEvent), () => Console.WriteLine("I am invoked before 'Test event received'"), priority: 2); + CoroutineHandler.InvokeLater(new Wait(TestEvent), () => Console.WriteLine("I am invoked after 'Example event received'"), priority: -5); + CoroutineHandler.InvokeLater(new Wait(TestEvent), () => Console.WriteLine("I am invoked before 'Example event received'"), priority: 2); var lastTime = DateTime.Now; while (true) { diff --git a/Example/Example.csproj b/Example/Example.csproj new file mode 100644 index 0000000..16e8042 --- /dev/null +++ b/Example/Example.csproj @@ -0,0 +1,11 @@ + + + netcoreapp3.1 + Exe + false + + + + + + diff --git a/Jenkinsfile b/Jenkinsfile index 27613c9..09ef649 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,16 +1,18 @@ pipeline { agent any stages { - stage('Build') { + stage('Test') { steps { - sh 'dotnet build **/Coroutine.csproj' + sh 'dotnet test --collect:"XPlat Code Coverage"' + nunit testResultsPattern: '**/TestResults.xml' + cobertura coberturaReportFile: '**/coverage.cobertura.xml' } } stage('Pack') { steps { sh 'find . -type f -name \\\'*.nupkg\\\' -delete' - sh 'dotnet pack **/Coroutine.csproj --version-suffix ${BUILD_NUMBER}' + sh 'dotnet pack --version-suffix ${BUILD_NUMBER}' } } diff --git a/README.md b/README.md index 56f35ac..6493425 100644 --- a/README.md +++ b/README.md @@ -66,4 +66,4 @@ CoroutineHandler.RaiseEvent(TestEvent); ``` ## Additional Examples -For additional examples, take a look at the [Example class](https://github.com/Ellpeck/Coroutine/blob/master/Test/Example.cs). \ No newline at end of file +For additional examples, take a look at the [Example class](https://github.com/Ellpeck/Coroutine/blob/master/Example/Example.cs). \ No newline at end of file diff --git a/Test/Test.csproj b/Test/Test.csproj deleted file mode 100644 index aaf5e03..0000000 --- a/Test/Test.csproj +++ /dev/null @@ -1,58 +0,0 @@ - - - - - Debug - AnyCPU - {8BE6B559-927D-47A6-8253-D7D809D337AF} - Exe - Properties - Test - Test - v4.6.2 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {1657964d-2503-426a-8514-d020660bee4d} - Coroutine - - - - - - diff --git a/CoroutineTests/EventBasedCoroutineTests.cs b/Tests/EventBasedCoroutineTests.cs similarity index 69% rename from CoroutineTests/EventBasedCoroutineTests.cs rename to Tests/EventBasedCoroutineTests.cs index 853b5f8..eb90b10 100644 --- a/CoroutineTests/EventBasedCoroutineTests.cs +++ b/Tests/EventBasedCoroutineTests.cs @@ -1,19 +1,16 @@ -using Coroutine; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Collections.Generic; +using System.Collections.Generic; +using Coroutine; +using NUnit.Framework; -namespace CoroutineTests -{ - [TestClass] - public class EventBasedCoroutineTests - { - [TestMethod] - public void TestEventBasedCoroutine() - { - int counter = 0; +namespace Tests { + public class EventBasedCoroutineTests { + + [Test] + public void TestEventBasedCoroutine() { + var counter = 0; var myEvent = new Event(); - IEnumerator OnEventTriggered() - { + + IEnumerator OnEventTriggered() { counter++; yield return new Wait(myEvent); counter++; @@ -30,5 +27,6 @@ namespace CoroutineTests Assert.AreEqual(false, cr.WasCanceled, "Incorrect IsCanceled value."); Assert.AreEqual(cr.MoveNextCount, 2, "Incorrect MoveNextCount value."); } + } -} +} \ No newline at end of file diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj new file mode 100644 index 0000000..6746a39 --- /dev/null +++ b/Tests/Tests.csproj @@ -0,0 +1,19 @@ + + + netcoreapp3.1 + false + nunit + + + + + + + + + + + + + + diff --git a/CoroutineTests/TimeBasedCoroutineTests.cs b/Tests/TimeBasedCoroutineTests.cs similarity index 55% rename from CoroutineTests/TimeBasedCoroutineTests.cs rename to Tests/TimeBasedCoroutineTests.cs index 615c322..0dbea33 100644 --- a/CoroutineTests/TimeBasedCoroutineTests.cs +++ b/Tests/TimeBasedCoroutineTests.cs @@ -1,20 +1,16 @@ using System.Collections.Generic; using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Coroutine; +using NUnit.Framework; +namespace Tests { + public class TimeBasedCoroutineTests { -namespace CoroutineTests -{ - [TestClass] - public class TimeBasedCoroutineTests - { - [TestMethod] - public void TestTimerBasedCoroutine() - { - int counter = 0; - IEnumerator OnTimeTickCodeExecuted() - { + [Test] + public void TestTimerBasedCoroutine() { + var counter = 0; + + IEnumerator OnTimeTickCodeExecuted() { counter++; yield return new Wait(0.1d); counter++; @@ -24,7 +20,7 @@ namespace CoroutineTests Assert.AreEqual(1, counter, "instruction before yield is not executed."); Assert.AreEqual(string.Empty, cr.Name, "Incorrect default name found"); Assert.AreEqual(0, cr.Priority, "Default priority is not minimum"); - for (int i = 0; i < 5; i++) + for (var i = 0; i < 5; i++) this.SimulateTime(1); Assert.AreEqual(2, counter, "instruction after yield is not executed."); Assert.AreEqual(true, cr.IsFinished, "Incorrect IsFinished value."); @@ -32,159 +28,143 @@ namespace CoroutineTests Assert.AreEqual(cr.MoveNextCount, 2, "Incorrect MoveNextCount value."); } - [TestMethod] - public void TestCoroutineReturningWeirdYields() - { - int counter = 0; - IEnumerator OnTimeTickNeverReturnYield() - { - counter++; // 1 - if (counter == 100) // condition that's expected to be false. - { - yield return new Wait(0.1d); - } + [Test] + public void TestCoroutineReturningWeirdYields() { + var counter = 0; + IEnumerator OnTimeTickNeverReturnYield() { + counter++; // 1 + // condition that's expected to be false + if (counter == 100) + yield return new Wait(0.1d); counter++; // 2 } - IEnumerator OnTimeTickYieldBreak() - { + IEnumerator OnTimeTickYieldBreak() { counter++; // 3 yield break; - counter++; // still 3 } var cr = new ActiveCoroutine[2]; cr[0] = CoroutineHandler.Start(OnTimeTickNeverReturnYield()); cr[1] = CoroutineHandler.Start(OnTimeTickYieldBreak()); - for (int i = 0; i < 5; i++) + for (var i = 0; i < 5; i++) this.SimulateTime(1); - Assert.AreEqual(3, counter, $"Incorrect counter value."); - for (int i = 0; i < cr.Length; i++) - { + Assert.AreEqual(3, counter, "Incorrect counter value."); + for (var i = 0; i < cr.Length; i++) { Assert.AreEqual(true, cr[i].IsFinished, $"Incorrect IsFinished value on index {i}."); Assert.AreEqual(false, cr[i].WasCanceled, $"Incorrect IsCanceled value on index {i}"); Assert.AreEqual(1, cr[i].MoveNextCount, $"Incorrect MoveNextCount value on index {i}"); } } - [TestMethod] - public void TestCoroutineReturningDefaultYield() - { - int counter = 0; - IEnumerator OnTimeTickYieldDefault() - { + [Test] + public void TestCoroutineReturningDefaultYield() { + var counter = 0; + + IEnumerator OnTimeTickYieldDefault() { counter++; // 1 yield return default; counter++; // 2 } var cr = CoroutineHandler.Start(OnTimeTickYieldDefault()); - for (int i = 0; i < 5; i++) + for (var i = 0; i < 5; i++) this.SimulateTime(1); - Assert.AreEqual(2, counter, $"Incorrect counter value."); - Assert.AreEqual(true, cr.IsFinished, $"Incorrect IsFinished value."); - Assert.AreEqual(false, cr.WasCanceled, $"Incorrect IsCanceled value."); - Assert.AreEqual(2, cr.MoveNextCount, $"Incorrect MoveNextCount value."); + Assert.AreEqual(2, counter, "Incorrect counter value."); + Assert.AreEqual(true, cr.IsFinished, "Incorrect IsFinished value."); + Assert.AreEqual(false, cr.WasCanceled, "Incorrect IsCanceled value."); + Assert.AreEqual(2, cr.MoveNextCount, "Incorrect MoveNextCount value."); } - [TestMethod] - public void TestInfiniteCoroutineNeverFinishesUnlessCanceled() - { - int counter = 0; - IEnumerator OnTimerTickInfinite() - { - while (true) - { + [Test] + public void TestInfiniteCoroutineNeverFinishesUnlessCanceled() { + var counter = 0; + + IEnumerator OnTimerTickInfinite() { + while (true) { counter++; yield return new Wait(1); } } - void setCounterToUnreachableValue(ActiveCoroutine coroutine) - { + void SetCounterToUnreachableValue(ActiveCoroutine coroutine) { counter = -100; } var cr = CoroutineHandler.Start(OnTimerTickInfinite()); - cr.OnFinished += setCounterToUnreachableValue; - for (int i = 0; i < 50; i++) + cr.OnFinished += SetCounterToUnreachableValue; + for (var i = 0; i < 50; i++) this.SimulateTime(1); - Assert.AreEqual(51, counter, $"Incorrect counter value."); - Assert.AreEqual(false, cr.IsFinished, $"Incorrect IsFinished value."); - Assert.AreEqual(false, cr.WasCanceled, $"Incorrect IsCanceled value."); - Assert.AreEqual(51, cr.MoveNextCount, $"Incorrect MoveNextCount value."); + Assert.AreEqual(51, counter, "Incorrect counter value."); + Assert.AreEqual(false, cr.IsFinished, "Incorrect IsFinished value."); + Assert.AreEqual(false, cr.WasCanceled, "Incorrect IsCanceled value."); + Assert.AreEqual(51, cr.MoveNextCount, "Incorrect MoveNextCount value."); cr.Cancel(); - Assert.AreEqual(true, cr.WasCanceled, $"Incorrect IsCanceled value after canceling."); - Assert.AreEqual(-100, counter, $"OnFinished event not triggered when canceled."); - Assert.AreEqual(51, cr.MoveNextCount, $"Incorrect MoveNextCount value."); - Assert.AreEqual(true, cr.IsFinished, $"Incorrect IsFinished value."); + Assert.AreEqual(true, cr.WasCanceled, "Incorrect IsCanceled value after canceling."); + Assert.AreEqual(-100, counter, "OnFinished event not triggered when canceled."); + Assert.AreEqual(51, cr.MoveNextCount, "Incorrect MoveNextCount value."); + Assert.AreEqual(true, cr.IsFinished, "Incorrect IsFinished value."); } - [TestMethod] - public void TestOnFinishedEventExecuted() - { - int counter = 0; - IEnumerator OnTimeTick() - { + [Test] + public void TestOnFinishedEventExecuted() { + var counter = 0; + + IEnumerator OnTimeTick() { counter++; yield return new Wait(0.1d); } - void setCounterToUnreachableValue(ActiveCoroutine coroutine) - { + void SetCounterToUnreachableValue(ActiveCoroutine coroutine) { counter = -100; } var cr = CoroutineHandler.Start(OnTimeTick()); - cr.OnFinished += setCounterToUnreachableValue; + cr.OnFinished += SetCounterToUnreachableValue; this.SimulateTime(50); - Assert.AreEqual(-100, counter, $"Incorrect counter value."); + Assert.AreEqual(-100, counter, "Incorrect counter value."); } - [TestMethod] - public void TestNestedCoroutine() - { - int counterAlwaysRunning = 0; - IEnumerator AlwaysRunning() - { - while (true) - { + [Test] + public void TestNestedCoroutine() { + var counterAlwaysRunning = 0; + + IEnumerator AlwaysRunning() { + while (true) { yield return new Wait(1); counterAlwaysRunning++; } } - int counterChild = 0; - IEnumerator Child() - { + var counterChild = 0; + + IEnumerator Child() { yield return new Wait(1); counterChild++; } - int counterParent = 0; - IEnumerator Parent() - { + var counterParent = 0; + + IEnumerator Parent() { yield return new Wait(1); counterParent++; // OnFinish I will start child. } - int counterGrandParent = 0; - IEnumerator GrandParent() - { + var counterGrandParent = 0; + + IEnumerator GrandParent() { yield return new Wait(1); counterGrandParent++; - // Nested corotuine starting. var p = CoroutineHandler.Start(Parent()); - // Nested corotuine starting in OnFinished. - p.OnFinished += (ActiveCoroutine ac) => { CoroutineHandler.Start(Child()); }; + p.OnFinished += ac => CoroutineHandler.Start(Child()); } CoroutineHandler.Start(AlwaysRunning()); @@ -215,57 +195,50 @@ namespace CoroutineTests Assert.AreEqual(1, counterChild, "Child counter is invalid at time 4."); } - [TestMethod] - public void TestPriority() - { - int counterShouldExecuteBefore0 = 0; - IEnumerator ShouldExecuteBefore0() - { - while (true) - { + [Test] + public void TestPriority() { + var counterShouldExecuteBefore0 = 0; + + IEnumerator ShouldExecuteBefore0() { + while (true) { yield return new Wait(1); counterShouldExecuteBefore0++; } } - int counterShouldExecuteBefore1 = 0; - IEnumerator ShouldExecuteBefore1() - { - while (true) - { + var counterShouldExecuteBefore1 = 0; + + IEnumerator ShouldExecuteBefore1() { + while (true) { yield return new Wait(1); counterShouldExecuteBefore1++; } } - int counterShouldExecuteAfter = 0; - IEnumerator ShouldExecuteAfter() - { - while (true) - { + var counterShouldExecuteAfter = 0; + + IEnumerator ShouldExecuteAfter() { + while (true) { yield return new Wait(1); if (counterShouldExecuteBefore0 == 1 && - counterShouldExecuteBefore1 == 1) - { + counterShouldExecuteBefore1 == 1) { counterShouldExecuteAfter++; } } } - int counterShouldExecuteFinally = 0; - IEnumerator ShouldExecuteFinally() - { - while (true) - { + var counterShouldExecuteFinally = 0; + + IEnumerator ShouldExecuteFinally() { + while (true) { yield return new Wait(1); - if (counterShouldExecuteAfter > 0) - { + if (counterShouldExecuteAfter > 0) { counterShouldExecuteFinally++; } } } - int highPriority = int.MaxValue; + var highPriority = int.MaxValue; CoroutineHandler.Start(ShouldExecuteBefore1(), priority: highPriority); CoroutineHandler.Start(ShouldExecuteAfter()); CoroutineHandler.Start(ShouldExecuteBefore0(), priority: highPriority); @@ -275,24 +248,21 @@ namespace CoroutineTests Assert.AreEqual(1, counterShouldExecuteFinally, $"ShouldExecuteFinally counter {counterShouldExecuteFinally} is invalid."); } - [TestMethod] - public void TestTimeBasedCoroutineIsAccurate() - { - int counter0 = 0; - IEnumerator IncrementCounter0Ever10Seconds() - { - while (true) - { + [Test] + public void TestTimeBasedCoroutineIsAccurate() { + var counter0 = 0; + + IEnumerator IncrementCounter0Ever10Seconds() { + while (true) { yield return new Wait(10); counter0++; } } - int counter1 = 0; - IEnumerator IncrementCounter1Every5Seconds() - { - while (true) - { + var counter1 = 0; + + IEnumerator IncrementCounter1Every5Seconds() { + while (true) { yield return new Wait(5); counter1++; } @@ -301,69 +271,66 @@ namespace CoroutineTests CoroutineHandler.Start(IncrementCounter0Ever10Seconds()); CoroutineHandler.Start(IncrementCounter1Every5Seconds()); this.SimulateTime(3); - Assert.AreEqual(0, counter0, $"Incorrect counter0 value after 3 seconds."); - Assert.AreEqual(0, counter1, $"Incorrect counter1 value after 3 seconds."); + Assert.AreEqual(0, counter0, "Incorrect counter0 value after 3 seconds."); + Assert.AreEqual(0, counter1, "Incorrect counter1 value after 3 seconds."); this.SimulateTime(3); - Assert.AreEqual(0, counter0, $"Incorrect counter0 value after 6 seconds."); - Assert.AreEqual(1, counter1, $"Incorrect counter1 value after 6 seconds."); + Assert.AreEqual(0, counter0, "Incorrect counter0 value after 6 seconds."); + Assert.AreEqual(1, counter1, "Incorrect counter1 value after 6 seconds."); // it's 5 over here because IncrementCounter1Every5Seconds // increments 5 seconds after last yield. not 5 seconds since start. // So the when we send 3 seconds in the last SimulateTime, // the 3rd second was technically ignored. this.SimulateTime(5); - Assert.AreEqual(1, counter0, $"Incorrect counter0 value after 10 seconds."); - Assert.AreEqual(2, counter1, $"Incorrect counter1 value after next 5 seconds."); + Assert.AreEqual(1, counter0, "Incorrect counter0 value after 10 seconds."); + Assert.AreEqual(2, counter1, "Incorrect counter1 value after next 5 seconds."); } - [TestMethod] - public void InvokeLaterAndNameTest() - { - int counter = 0; + [Test] + public void InvokeLaterAndNameTest() { + var counter = 0; var cr = CoroutineHandler.InvokeLater(new Wait(10), () => { counter++; }, "Bird"); this.SimulateTime(5); - Assert.AreEqual(0, counter, $"Incorrect counter value after 5 seconds."); + Assert.AreEqual(0, counter, "Incorrect counter value after 5 seconds."); this.SimulateTime(5); - Assert.AreEqual(1, counter, $"Incorrect counter value after 10 seconds."); + Assert.AreEqual(1, counter, "Incorrect counter value after 10 seconds."); Assert.AreEqual(true, cr.IsFinished, "Incorrect IsFinished value."); Assert.AreEqual(false, cr.WasCanceled, "Incorrect IsCanceled value."); Assert.AreEqual(cr.MoveNextCount, 2, "Incorrect MoveNextCount value."); Assert.AreEqual(cr.Name, "Bird", "Incorrect name of the coroutine."); } - [TestMethod] - public void CoroutineStatsAre95PercentAccurate() - { - IEnumerator CoroutineTakesMax500MS() - { + [Test] + public void CoroutineStatsAre95PercentAccurate() { + IEnumerator CoroutineTakesMax500Ms() { Thread.Sleep(200); yield return new Wait(10); Thread.Sleep(500); } - var cr = CoroutineHandler.Start(CoroutineTakesMax500MS()); - for (int i = 0; i < 5; i++) + var cr = CoroutineHandler.Start(CoroutineTakesMax500Ms()); + for (var i = 0; i < 5; i++) this.SimulateTime(50); - int expected1 = 350; - float errorbar1 = (5 / 100f * expected1); - bool gTA = cr.AverageMoveNextTime.Milliseconds > (expected1 - errorbar1); // 95% accuracy. - bool lTB = cr.AverageMoveNextTime.Milliseconds < (expected1 + errorbar1); // 95% accuracy. - Assert.IsTrue(gTA && lTB, $"Average Move Next Time {cr.AverageMoveNextTime.Milliseconds} is invalid."); + const int expected1 = 350; + const float errorbar1 = 5 / 100f * expected1; + var gTa = cr.AverageMoveNextTime.Milliseconds > expected1 - errorbar1; // 95% accuracy. + var lTb = cr.AverageMoveNextTime.Milliseconds < expected1 + errorbar1; // 95% accuracy. + Assert.IsTrue(gTa && lTb, $"Average Move Next Time {cr.AverageMoveNextTime.Milliseconds} is invalid."); - int expected2 = 500; - float errorbar2 = (5 / 100f * expected2); - bool gTC = cr.MaxMoveNextTime.Milliseconds > (expected2 - errorbar2); // 95% accuracy. - bool lTD = cr.MaxMoveNextTime.Milliseconds < (expected2 + errorbar2); // 95% accuracy. - Assert.IsTrue(gTC && lTD, $"Maximum Move Next Time {cr.MaxMoveNextTime.Milliseconds} is invalid."); + const int expected2 = 500; + const float errorbar2 = 5 / 100f * expected2; + var gTc = cr.MaxMoveNextTime.Milliseconds > expected2 - errorbar2; // 95% accuracy. + var lTd = cr.MaxMoveNextTime.Milliseconds < expected2 + errorbar2; // 95% accuracy. + Assert.IsTrue(gTc && lTd, $"Maximum Move Next Time {cr.MaxMoveNextTime.Milliseconds} is invalid."); } - private void SimulateTime(double totalSeconds) - { + private void SimulateTime(double totalSeconds) { CoroutineHandler.Tick(totalSeconds); } + } -} +} \ No newline at end of file