Index: Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs =================================================================== diff -u -rad66b6e2df465acc900aa792c99dfdacee3f3a32 -rac16d6c29bbb756651b4f8a25e58fd9b5e0f9c67 --- Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs (.../TestHelperTest.cs) (revision ad66b6e2df465acc900aa792c99dfdacee3f3a32) +++ Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs (.../TestHelperTest.cs) (revision ac16d6c29bbb756651b4f8a25e58fd9b5e0f9c67) @@ -250,7 +250,7 @@ path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO); Assert.IsTrue(Directory.Exists(path)); - + path = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Revetment.IO); Assert.IsTrue(Directory.Exists(path)); } @@ -1153,6 +1153,24 @@ Assert.Throws(test); } + [Test] + public void PerformActionWithDelayedAssert_WithAllData_DoesNotThrow() + { + // Setup + var callPerformed = false; + var assertPerformed = false; + var callAction = new Action(() => callPerformed = true); + var assertAction = new Action(() => assertPerformed = true); + const int delay = 10; + + // Call + TestHelper.PerformActionWithDelayedAssert(callAction, assertAction, delay); + + // Assert + Assert.IsTrue(callPerformed); + Assert.IsTrue(assertPerformed); + } + private class TestEqualSameObject { private readonly int someInt; @@ -1168,14 +1186,17 @@ { return false; } + if (ReferenceEquals(this, obj)) { return true; } + if (obj.GetType() != GetType()) { return false; } + return Equals((TestEqualSameObject) obj); } Index: Core/Common/test/Core.Common.TestUtil/TestHelper.cs =================================================================== diff -u -rfb6ca0c708e591684db8b4e877ec4c38b094b5c9 -rac16d6c29bbb756651b4f8a25e58fd9b5e0f9c67 --- Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision fb6ca0c708e591684db8b4e877ec4c38b094b5c9) +++ Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision ac16d6c29bbb756651b4f8a25e58fd9b5e0f9c67) @@ -35,6 +35,7 @@ using log4net.Core; using NUnit.Framework; using NUnit.Framework.Internal; +using Timer = System.Timers.Timer; namespace Core.Common.TestUtil { @@ -66,6 +67,7 @@ { Directory.CreateDirectory(scratchPadPath); } + return scratchPadPath; } @@ -113,6 +115,7 @@ try { using (File.OpenWrite(pathToFile)) {} + return true; } catch (IOException) @@ -269,6 +272,7 @@ Assert.IsNull(actualImage); return; } + Assert.IsNotNull(actualImage); Assert.AreEqual(expectedImage.Size, actualImage.Size); @@ -337,6 +341,7 @@ message = string.Join(Environment.NewLine, customMessageParts.ToArray()); } + Assert.AreEqual(expectedCustomMessage, message); return exception; } @@ -470,6 +475,7 @@ Assert.AreSame(expectedEnumerator.Current, actualEnumerator.Current); } } + Assert.IsFalse(actualEnumerator.MoveNext()); } @@ -497,6 +503,7 @@ Assert.AreNotSame(expectedEnumerator.Current, actualEnumerator.Current); } } + Assert.IsFalse(actualEnumerator.MoveNext()); } @@ -531,11 +538,39 @@ Assert.IsTrue(equalityComparer.Equals(expectedEnumerator.Current, actualEnumerator.Current)); } } + Assert.IsFalse(actualEnumerator.MoveNext()); } } /// + /// Performs the call and asserts after the delay has passed. + /// + /// The call to perform. + /// The assert to perform. + /// The delay by which the assert action is performed + /// after the call action is done. + /// Thrown when an assert in the + /// failed. + public static void PerformActionWithDelayedAssert(Action callAction, Action assertAction, int delay) + { + var timer = new Timer + { + Interval = delay + }; + + var timerEnded = false; + timer.Elapsed += (sender, args) => { timerEnded = true; }; + + callAction(); + timer.Start(); + + while (!timerEnded) {} + + assertAction(); + } + + /// /// Determines whether a class is decorated with a /// of a given type. /// @@ -705,6 +740,7 @@ imageColors[index++] = bitmap.GetPixel(j, i); } } + return imageColors; } }