Skip to content

Commit

Permalink
Bump xunit from 2.5.0 to 2.5.1 (#375)
Browse files Browse the repository at this point in the history
* Bump xunit from 2.5.0 to 2.5.1

Bumps [xunit](https://github.com/xunit/xunit) from 2.5.0 to 2.5.1.
- [Commits](xunit/xunit@2.5.0...2.5.1)

---
updated-dependencies:
- dependency-name: xunit
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

* Make tests xUnit 2.5.1 compatible

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gregorius Soedharmo <[email protected]>
  • Loading branch information
dependabot[bot] and Arkatufus authored Sep 26, 2023
1 parent b36e758 commit d0aa2fe
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ public void TestActorRef_name_must_start_with_double_dollar_sign()
}

[Fact]
public void TestActorRef_must_support_nested_Actor_creation_when_used_with_TestActorRef()
public async Task TestActorRef_must_support_nested_Actor_creation_when_used_with_TestActorRef()
{
var a = new TestActorRef<NestingActor>(Sys, Props.Create(() => new NestingActor(true)));
Assert.NotNull(a);
var nested = a.Ask<IActorRef>("any", DefaultTimeout).Result;
var nested = await a.Ask<IActorRef>("any", DefaultTimeout);
Assert.NotNull(nested);
Assert.NotSame(a, nested);
}

[Fact]
public void TestActorRef_must_support_nested_Actor_creation_when_used_with_ActorRef()
public async Task TestActorRef_must_support_nested_Actor_creation_when_used_with_ActorRef()
{
var a = new TestActorRef<NestingActor>(Sys, Props.Create(() => new NestingActor(false)));
Assert.NotNull(a);
var nested = a.Ask<IActorRef>("any", DefaultTimeout).Result;
var nested = await a.Ask<IActorRef>("any", DefaultTimeout);
Assert.NotNull(nested);
Assert.NotSame(a, nested);
}
Expand Down Expand Up @@ -135,13 +135,13 @@ public void TestActorRef_must_restart_when_killed()
}

[Fact]
public void TestActorRef_must_support_futures()
public async Task TestActorRef_must_support_futures()
{
var worker = new TestActorRef<WorkerActor>(Sys, Props.Create<WorkerActor>());
var task = worker.Ask("work");
Assert.True(task.IsCompleted, "Task should be completed");
if(!task.Wait(DefaultTimeout)) throw new TimeoutException("Timed out"); //Using a timeout to stop the test if there is something wrong with the code
Assert.Equal("workDone", task.Result);
var result = await task.WaitAsync(DefaultTimeout); //Using a timeout to stop the test if there is something wrong with the code
Assert.Equal("workDone", result);
}

[Fact]
Expand Down
64 changes: 32 additions & 32 deletions src/Akka.Hosting.TestKit.Tests/TestSchedulerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,95 +36,95 @@ protected override async Task BeforeTestStart()
protected override Config Config { get; } = TestConfigs.TestSchedulerConfig;

[Fact]
public void Delivers_message_when_scheduled_time_reached()
public async Task Delivers_message_when_scheduled_time_reached()
{
_testReceiveActor.Tell(new ScheduleOnceMessage(TimeSpan.FromSeconds(1)));
_testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault)
.Wait(RemainingOrDefault).Should().BeTrue(); // verify that the ActorCell has started
(await _testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault).WaitAsync(RemainingOrDefault))
.Should().BeOfType<ActorIdentity>(); // verify that the ActorCell has started

Scheduler.Advance(TimeSpan.FromSeconds(1));
ExpectMsg<ScheduleOnceMessage>();
await ExpectMsgAsync<ScheduleOnceMessage>();
}

[Fact]
public void Does_not_deliver_message_prematurely()
public async Task Does_not_deliver_message_prematurely()
{
_testReceiveActor.Tell(new ScheduleOnceMessage(TimeSpan.FromSeconds(1)));
_testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault)
.Wait(RemainingOrDefault).Should().BeTrue(); // verify that the ActorCell has started
(await _testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault).WaitAsync(RemainingOrDefault))
.Should().BeOfType<ActorIdentity>(); // verify that the ActorCell has started

Scheduler.Advance(TimeSpan.FromMilliseconds(999));
ExpectNoMsg(TimeSpan.FromMilliseconds(20));
await ExpectNoMsgAsync(TimeSpan.FromMilliseconds(20));
}

[Fact]
public void Delivers_messages_scheduled_for_same_time_in_order_they_were_added()
public async Task Delivers_messages_scheduled_for_same_time_in_order_they_were_added()
{
_testReceiveActor.Tell(new ScheduleOnceMessage(TimeSpan.FromSeconds(1), 1));
_testReceiveActor.Tell(new ScheduleOnceMessage(TimeSpan.FromSeconds(1), 2));
_testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault)
.Wait(RemainingOrDefault).Should().BeTrue(); // verify that the ActorCell has started
(await _testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault).WaitAsync(RemainingOrDefault))
.Should().BeOfType<ActorIdentity>(); // verify that the ActorCell has started

Scheduler.Advance(TimeSpan.FromSeconds(1));
var firstId = ExpectMsg<ScheduleOnceMessage>().Id;
var secondId = ExpectMsg<ScheduleOnceMessage>().Id;
var firstId = (await ExpectMsgAsync<ScheduleOnceMessage>()).Id;
var secondId = (await ExpectMsgAsync<ScheduleOnceMessage>()).Id;
Assert.Equal(1, firstId);
Assert.Equal(2, secondId);
}

[Fact]
public void Keeps_delivering_rescheduled_message()
public async Task Keeps_delivering_rescheduled_message()
{
_testReceiveActor.Tell(new RescheduleMessage(TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(5)));
_testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault)
.Wait(RemainingOrDefault).Should().BeTrue(); // verify that the ActorCell has started
(await _testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault).WaitAsync(RemainingOrDefault))
.Should().BeOfType<ActorIdentity>(); // verify that the ActorCell has started

for (int i = 0; i < 500; i ++)
{
Scheduler.Advance(TimeSpan.FromSeconds(5));
ExpectMsg<RescheduleMessage>();
await ExpectMsgAsync<RescheduleMessage>();
}
}

[Fact]
public void Uses_initial_delay_to_schedule_first_rescheduled_message()
public async Task Uses_initial_delay_to_schedule_first_rescheduled_message()
{
_testReceiveActor.Tell(new RescheduleMessage(TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(5)));
_testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault)
.Wait(RemainingOrDefault).Should().BeTrue(); // verify that the ActorCell has started
(await _testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault).WaitAsync(RemainingOrDefault))
.Should().BeOfType<ActorIdentity>(); // verify that the ActorCell has started

Scheduler.Advance(TimeSpan.FromSeconds(1));
ExpectMsg<RescheduleMessage>();
await ExpectMsgAsync<RescheduleMessage>();
}

[Fact]
public void Doesnt_reschedule_cancelled()
public async Task Doesnt_reschedule_cancelled()
{
_testReceiveActor.Tell(new CancelableMessage(TimeSpan.FromSeconds(1)));
_testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault)
.Wait(RemainingOrDefault).Should().BeTrue(); // verify that the ActorCell has started
(await _testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault).WaitAsync(RemainingOrDefault))
.Should().BeOfType<ActorIdentity>(); // verify that the ActorCell has started

Scheduler.Advance(TimeSpan.FromSeconds(1));
ExpectMsg<CancelableMessage>();
await ExpectMsgAsync<CancelableMessage>();
_testReceiveActor.Tell(new CancelMessage());
Scheduler.Advance(TimeSpan.FromSeconds(1));
ExpectNoMsg(TimeSpan.FromMilliseconds(20));
await ExpectNoMsgAsync(TimeSpan.FromMilliseconds(20));
}


[Fact]
public void Advance_to_takes_us_to_correct_time()
public async Task Advance_to_takes_us_to_correct_time()
{
_testReceiveActor.Tell(new ScheduleOnceMessage(TimeSpan.FromSeconds(1), 1));
_testReceiveActor.Tell(new ScheduleOnceMessage(TimeSpan.FromSeconds(2), 2));
_testReceiveActor.Tell(new ScheduleOnceMessage(TimeSpan.FromSeconds(3), 3));
_testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault)
.Wait(RemainingOrDefault).Should().BeTrue(); // verify that the ActorCell has started
(await _testReceiveActor.Ask<ActorIdentity>(new Identify(null), RemainingOrDefault).WaitAsync(RemainingOrDefault))
.Should().BeOfType<ActorIdentity>(); // verify that the ActorCell has started

Scheduler.AdvanceTo(Scheduler.Now.AddSeconds(2));
var firstId = ExpectMsg<ScheduleOnceMessage>().Id;
var secondId = ExpectMsg<ScheduleOnceMessage>().Id;
ExpectNoMsg(TimeSpan.FromMilliseconds(20));
var firstId = (await ExpectMsgAsync<ScheduleOnceMessage>()).Id;
var secondId = (await ExpectMsgAsync<ScheduleOnceMessage>()).Id;
await ExpectNoMsgAsync(TimeSpan.FromMilliseconds(20));
Assert.Equal(1, firstId);
Assert.Equal(2, secondId);
}
Expand Down
13 changes: 6 additions & 7 deletions src/Akka.Hosting.Tests/ActorRegistrySpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Akka.Actor;
using FluentAssertions;
using Xunit;
using static FluentAssertions.FluentActions;

namespace Akka.Hosting.Tests;

Expand Down Expand Up @@ -129,21 +130,19 @@ public void GetAsync_should_return_CompletedTask_if_Key_AlreadyExists()
}

[Fact]
public void GetAsync_should_Cancel_after_Timeout()
public async Task GetAsync_should_Cancel_after_Timeout()
{
// arrange
var registry = new ActorRegistry();
var cancellationTokenSource = new CancellationTokenSource();

// act
var task = registry.GetAsync<Nobody>(cancellationTokenSource.Token);
Action cancel = () =>
// assert
await Awaiting(async () =>
{
cancellationTokenSource.Cancel();
task.Wait(TimeSpan.FromSeconds(3));
};

// assert
cancel.Should().Throw<TaskCanceledException>();
await task.WaitAsync(TimeSpan.FromSeconds(3));
}).Should().ThrowAsync<TaskCanceledException>();
}
}
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PropertyGroup>
<LibraryFramework>netstandard2.0</LibraryFramework>
<TestsNetCoreFramework>net6.0</TestsNetCoreFramework>
<XunitVersion>2.5.0</XunitVersion>
<XunitVersion>2.5.1</XunitVersion>
<TestSdkVersion>17.7.2</TestSdkVersion>
<CoverletVersion>6.0.0</CoverletVersion>
<XunitRunneVisualstudio>2.5.1</XunitRunneVisualstudio>
Expand Down

0 comments on commit d0aa2fe

Please sign in to comment.