Skip to content

Commit

Permalink
Update NUnit to 4.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
ocoanet committed Nov 30, 2024
1 parent b2aa9d5 commit 63ec917
Show file tree
Hide file tree
Showing 41 changed files with 512 additions and 504 deletions.
10 changes: 5 additions & 5 deletions src/Disruptor.Tests/AggregateEventHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ private static void AssertLastEvent(int[] evt, long sequence, params DummyEventH
{
foreach (var handler in handlers)
{
Assert.AreSame(handler.LastEvent, evt);
Assert.AreEqual(handler.LastSequence, sequence);
Assert.That(evt, Is.SameAs(handler.LastEvent));
Assert.That(sequence, Is.EqualTo(handler.LastSequence));
}
}

private static void AssertStartCalls(int startCalls, params DummyEventHandler<int[]>[] handlers)
{
foreach (var handler in handlers)
{
Assert.AreEqual(handler.StartCalls, startCalls);
Assert.That(startCalls, Is.EqualTo(handler.StartCalls));
}
}

private static void AssertShutdownCalls(int shutdownCalls, params DummyEventHandler<int[]>[] handlers)
{
foreach (var handler in handlers)
{
Assert.AreEqual(handler.ShutdownCalls, shutdownCalls);
Assert.That(shutdownCalls, Is.EqualTo(handler.ShutdownCalls));
}
}
}
}
18 changes: 9 additions & 9 deletions src/Disruptor.Tests/AsyncEventStreamTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void ShouldProcessEventsPublishedDuringIteration()
}
}
// Assert
Assert.IsTrue(task.Wait(TimeSpan.FromSeconds(2)));
Assert.That(task.Wait(TimeSpan.FromSeconds(2)));
Assert.That(processedValues, Is.EquivalentTo(publishedValues));
}

Expand Down Expand Up @@ -130,8 +130,8 @@ public void ShouldProcessEventsFromMultipleStreams()
}

// Assert
Assert.IsTrue(task1.Wait(TimeSpan.FromSeconds(2)));
Assert.IsTrue(task2.Wait(TimeSpan.FromSeconds(2)));
Assert.That(task1.Wait(TimeSpan.FromSeconds(2)));
Assert.That(task2.Wait(TimeSpan.FromSeconds(2)));
Assert.That(processedValues1, Is.EquivalentTo(publishedValues));
Assert.That(processedValues2, Is.EquivalentTo(publishedValues));
}
Expand Down Expand Up @@ -163,7 +163,7 @@ public void ShouldResetEnumeratorSequence()
_ringBuffer.PublishStubEvent(3);

// Assert
Assert.IsTrue(task.Wait(TimeSpan.FromSeconds(2)));
Assert.That(task.Wait(TimeSpan.FromSeconds(2)));
Assert.That(processedValues, Is.EquivalentTo(new[] { 3 }));
}

Expand All @@ -179,7 +179,7 @@ public void ShouldAddGatingSequence()

var canGetNextSequence = _ringBuffer.TryNext(out _);

Assert.IsFalse(canGetNextSequence);
Assert.That(!canGetNextSequence);
}

[Test]
Expand All @@ -196,7 +196,7 @@ public void ShouldRemoveGatingSequenceOnDispose()

var canGetNextSequence = _ringBuffer.TryNext(out _);

Assert.IsTrue(canGetNextSequence);
Assert.That(canGetNextSequence);
}

[Test]
Expand All @@ -216,7 +216,7 @@ public void ShouldStopIterationOnCancellation()

_ringBuffer.PublishStubEvent(0);

Assert.IsTrue(processingSignal.Wait(TimeSpan.FromSeconds(2)));
Assert.That(processingSignal.Wait(TimeSpan.FromSeconds(2)));

cancellationTokenSource.Cancel();

Expand All @@ -239,7 +239,7 @@ public void ShouldStopIterationOnStreamDispose()

_ringBuffer.PublishStubEvent(0);

Assert.IsTrue(processingSignal.Wait(TimeSpan.FromSeconds(2)));
Assert.That(processingSignal.Wait(TimeSpan.FromSeconds(2)));

stream.Dispose();

Expand All @@ -249,6 +249,6 @@ public void ShouldStopIterationOnStreamDispose()
private static void AssertIsCancelled(Task task)
{
var exception = Assert.Catch<AggregateException>(() => task.Wait(TimeSpan.FromSeconds(2)));
Assert.IsInstanceOf<TaskCanceledException>(exception!.InnerException);
Assert.That(exception!.InnerException, Is.InstanceOf<OperationCanceledException>());
}
}
8 changes: 4 additions & 4 deletions src/Disruptor.Tests/DependentSequenceGroupTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public void ShouldGetCursorValue()

var cursorValue = dependentSequences.CursorValue;

Assert.AreEqual(42, cursorValue);
Assert.That(cursorValue, Is.EqualTo((long)42));
}

[Test]
Expand All @@ -26,7 +26,7 @@ public void ShouldGetCursorValueAsValueWhenThereAreNoDependentSequences()

var value = dependentSequences.Value;

Assert.AreEqual(42, value);
Assert.That(value, Is.EqualTo((long)42));
}

[Test, Repeat(10)]
Expand All @@ -43,7 +43,7 @@ public void ShouldGetMinimumValueFromSequences([Range(1, 4)] int dependencyCount
var value = dependentSequences.Value;

var expectedValue = sequences.Select(x => x.Value).Min();
Assert.AreEqual(expectedValue, value);
Assert.That(value, Is.EqualTo(expectedValue));
}

[TestCase(0, 1)]
Expand All @@ -58,6 +58,6 @@ public void ShouldGetDependentSequenceCount(int dependencyCount, int expectedDep

var dependentSequences = new DependentSequenceGroup(cursor, sequences);

Assert.AreEqual(expectedDependentSequenceCount, dependentSequences.DependentSequenceCount);
Assert.That(dependentSequences.DependentSequenceCount, Is.EqualTo(expectedDependentSequenceCount));
}
}
8 changes: 4 additions & 4 deletions src/Disruptor.Tests/Disruptor.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0;net8.0</TargetFrameworks>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand All @@ -11,9 +11,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/Disruptor.Tests/DisruptorUtilTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,30 @@ public void ShouldReturnNextPowerOfTwo()
{
var powerOfTwo = DisruptorUtil.CeilingNextPowerOfTwo(1000);

Assert.AreEqual(1024, powerOfTwo);
Assert.That(powerOfTwo, Is.EqualTo(1024));
}

[Test]
public void ShouldReturnExactPowerOfTwo()
{
var powerOfTwo = DisruptorUtil.CeilingNextPowerOfTwo(1024);

Assert.AreEqual(1024, powerOfTwo);
Assert.That(powerOfTwo, Is.EqualTo(1024));
}

[Test]
public void ShouldReturnMinimumSequence()
{
var sequences = new[] {new Sequence(11), new Sequence(4), new Sequence(13)};

Assert.AreEqual(4L, DisruptorUtil.GetMinimumSequence(sequences));
Assert.That(DisruptorUtil.GetMinimumSequence(sequences), Is.EqualTo(4L));
}

[Test]
public void ShouldReturnLongMaxWhenNoEventProcessors()
{
var sequences = new Sequence[0];

Assert.AreEqual(long.MaxValue, DisruptorUtil.GetMinimumSequence(sequences));
Assert.That(DisruptorUtil.GetMinimumSequence(sequences), Is.EqualTo(long.MaxValue));
}
}
}
4 changes: 2 additions & 2 deletions src/Disruptor.Tests/Dsl/ConsumerRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void ShouldIterateAllEventProcessors()
}
}

Assert.True(seen1, "Included eventProcessor 1");
Assert.True(seen2, "Included eventProcessor 2");
Assert.That(seen1, "Included eventProcessor 1");
Assert.That(seen2, "Included eventProcessor 2");
}
}
50 changes: 25 additions & 25 deletions src/Disruptor.Tests/Dsl/DisruptorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public void Dispose()
[Test]
public void ShouldHaveStartedAfterStartCalled()
{
Assert.IsFalse(_disruptor.HasStarted, "Should only be set to started after start is called");
Assert.That(!_disruptor.HasStarted, "Should only be set to started after start is called");

_disruptor.Start();

Assert.IsTrue(_disruptor.HasStarted, "Should be set to started after start is called");
Assert.That(_disruptor.HasStarted, "Should be set to started after start is called");
}

[Test]
Expand All @@ -70,8 +70,8 @@ public void ShouldPublishAndHandleEvent_EventHandler()
scope.Event().Value = 102;
}

Assert.IsTrue(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.AreEqual(new List<int> { 101, 102 }, values);
Assert.That(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.That(values, Is.EqualTo(new List<int> { 101, 102 }));
}

[Test]
Expand All @@ -94,8 +94,8 @@ public void ShouldPublishAndHandleEvent_BatchEventHandler()
scope.Event().Value = 102;
}

Assert.IsTrue(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.AreEqual(new List<int> { 101, 102 }, values);
Assert.That(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.That(values, Is.EqualTo(new List<int> { 101, 102 }));
}

[Test]
Expand All @@ -118,8 +118,8 @@ public void ShouldPublishAndHandleEvent_AsyncBatchEventHandler()
scope.Event().Value = 102;
}

Assert.IsTrue(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.AreEqual(new List<int> { 101, 102 }, values);
Assert.That(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.That(values, Is.EqualTo(new List<int> { 101, 102 }));
}

[Test]
Expand All @@ -144,8 +144,8 @@ public void ShouldPublishAndHandleEvents_EventHandler()
scope.Event(1).Value = 104;
}

Assert.IsTrue(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.AreEqual(new List<int> { 101, 102, 103, 104 }, values);
Assert.That(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.That(values, Is.EqualTo(new List<int> { 101, 102, 103, 104 }));
}

[Test]
Expand All @@ -170,8 +170,8 @@ public void ShouldPublishAndHandleEvents_BatchEventHandler()
scope.Event(1).Value = 104;
}

Assert.IsTrue(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.AreEqual(new List<int> { 101, 102, 103, 104 }, values);
Assert.That(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.That(values, Is.EqualTo(new List<int> { 101, 102, 103, 104 }));
}

[Test]
Expand All @@ -196,8 +196,8 @@ public void ShouldPublishAndHandleEvents_AsyncBatchEventHandler()
scope.Event(1).Value = 104;
}

Assert.IsTrue(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.AreEqual(new List<int> { 101, 102, 103, 104 }, values);
Assert.That(eventCounter.Wait(TimeSpan.FromSeconds(5)));
Assert.That(values, Is.EqualTo(new List<int> { 101, 102, 103, 104 }));
}

[Test]
Expand Down Expand Up @@ -376,7 +376,7 @@ public void ShouldCreateEventProcessorGroupForFirstEventProcessors()
var eventHandlerGroup = _disruptor.HandleEventsWith(eventHandler1, eventHandler2);
_disruptor.Start();

Assert.IsNotNull(eventHandlerGroup);
Assert.That(eventHandlerGroup, Is.Not.Null);
Assert.That(_taskScheduler.TaskCount, Is.EqualTo(2));
}

Expand Down Expand Up @@ -486,7 +486,7 @@ public void ShouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors_Ev
PublishEvent();

var actualException = WaitFor(eventHandled);
Assert.AreSame(testException, actualException);
Assert.That(actualException, Is.SameAs(testException));
}

[Test]
Expand All @@ -503,7 +503,7 @@ public void ShouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors_Ba
PublishEvent();

var actualException = WaitFor(eventHandled);
Assert.AreSame(testException, actualException);
Assert.That(actualException, Is.SameAs(testException));
}

[Test]
Expand All @@ -520,7 +520,7 @@ public void ShouldSupportSpecifyingADefaultExceptionHandlerForEventProcessors_As
PublishEvent();

var actualException = WaitFor(eventHandled);
Assert.AreSame(testException, actualException);
Assert.That(actualException, Is.SameAs(testException));
}

[Test]
Expand All @@ -537,7 +537,7 @@ public void ShouldApplyDefaultExceptionHandlerToExistingEventProcessors_EventHan
PublishEvent();

var actualException = WaitFor(eventHandled);
Assert.AreSame(testException, actualException);
Assert.That(actualException, Is.SameAs(testException));
}

[Test]
Expand All @@ -554,7 +554,7 @@ public void ShouldApplyDefaultExceptionHandlerToExistingEventProcessors_BatchEve
PublishEvent();

var actualException = WaitFor(eventHandled);
Assert.AreSame(testException, actualException);
Assert.That(actualException, Is.SameAs(testException));
}

[Test]
Expand All @@ -571,7 +571,7 @@ public void ShouldApplyDefaultExceptionHandlerToExistingEventProcessors_AsyncBat
PublishEvent();

var actualException = WaitFor(eventHandled);
Assert.AreSame(testException, actualException);
Assert.That(actualException, Is.SameAs(testException));
}

[Test]
Expand Down Expand Up @@ -946,7 +946,7 @@ public void ShouldMakeEntriesAvailableToFirstCustomProcessorsImmediately()

_disruptor.HandleEventsWith((rb, sequenceBarrier) =>
{
Assert.IsTrue(sequenceBarrier.DependentSequences.DependsOnCursor, "Should depend on cursor");
Assert.That(sequenceBarrier.DependentSequences.DependsOnCursor, "Should depend on cursor");
return EventProcessorFactory.Create(_disruptor.RingBuffer, sequenceBarrier, eventHandler);
});

Expand All @@ -962,8 +962,8 @@ public void ShouldHonorDependenciesForCustomProcessors()

_disruptor.HandleEventsWith(delayedEventHandler).Then((ringBuffer, sequenceBarrier) =>
{
Assert.IsFalse(sequenceBarrier.DependentSequences.DependsOnCursor, "Should not depend on cursor");
Assert.AreEqual(1, sequenceBarrier.DependentSequences.DependentSequenceCount, "Should have had a barrier sequence");
Assert.That(!sequenceBarrier.DependentSequences.DependsOnCursor, "Should not depend on cursor");
Assert.That(sequenceBarrier.DependentSequences.DependentSequenceCount, Is.EqualTo(1), "Should have had a barrier sequence");
return EventProcessorFactory.Create(ringBuffer, sequenceBarrier, eventHandler);
});

Expand Down Expand Up @@ -1033,6 +1033,6 @@ private void AssertThatCountDownLatchEquals(CountdownEvent countDownLatch, long
private void AssertThatCountDownLatchIsZero(CountdownEvent countDownLatch)
{
var released = countDownLatch.Wait(TimeSpan.FromSeconds(_timeoutInSeconds));
Assert.IsTrue(released, "Batch handler did not receive entries: " + countDownLatch.CurrentCount);
Assert.That(released, "Batch handler did not receive entries: " + countDownLatch.CurrentCount);
}
}
4 changes: 2 additions & 2 deletions src/Disruptor.Tests/Dsl/Stubs/StubPublisher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void AssertProducerReaches(int expectedPublicationCount, bool strict)
else
{
var actualPublicationCount = _publicationCount;
Assert.IsTrue(actualPublicationCount >= expectedPublicationCount, "Producer reached unexpected count. Expected at least " + expectedPublicationCount + " but only reached " + actualPublicationCount);
Assert.That(actualPublicationCount >= expectedPublicationCount, "Producer reached unexpected count. Expected at least " + expectedPublicationCount + " but only reached " + actualPublicationCount);
}
}
}
}
Loading

0 comments on commit 63ec917

Please sign in to comment.