Skip to content

Commit d6e8282

Browse files
authored
Work around issue with ToArray during SpinUntil (#102)
In `TestQueue.WaitFor()`, the use of the `HandledTypes` property was causing problems. That property converts from `HashSet<Type>` to `Array<Type>` using `ToArray()`. The conversion occasionally throws an ArgumentException, saying "Destination array is not long enough to copy all the items in the collection. Check array index and length." This error in turn causes unit tests that use `WaitFor` to occasionally fail. Because the exception is thrown from a core .NET library, we need to work around it, which we do by using the `_handledTypes` `HashSet` directly in `WaitFor()`.
1 parent 4a0e1fb commit d6e8282

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/ReactiveDomain.Testing/Specifications/TestQueue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void WaitFor<T>(TimeSpan timeout) where T : IMessage
114114
var msgType = typeof(T);
115115
do
116116
{
117-
if (SpinWait.SpinUntil(() => HandledTypes.Any(t => msgType.IsAssignableFrom(t)), 50))
117+
if (SpinWait.SpinUntil(() => _handledTypes.Any(t => msgType.IsAssignableFrom(t)), 50))
118118
{
119119
return;
120120
}

0 commit comments

Comments
 (0)