From b5349785cf4a0691c088b26efea01121cd0f8c62 Mon Sep 17 00:00:00 2001 From: "Elliott B. Edwards" <28941195+el2iot2@users.noreply.github.com> Date: Fri, 29 Jun 2018 22:29:46 -0700 Subject: [PATCH] Add Silo.CreateGrainAsync() support and tests (#43) * Add Silo.CreateGrainAsync() support and tests * CreateGrain -> CreateGrainAsync * Trigger[Start|Stop] -> ...Async * Updated version and Copyright year --- src/OrleansTestKit/OrleansTestKit.csproj | 4 +-- src/OrleansTestKit/TestGrainLifecycle.cs | 10 +++--- src/OrleansTestKit/TestKitSilo.cs | 34 +++++++++--------- .../Grains/StatefulActivationGrain.cs | 3 +- .../Tests/ActivationGrainTests.cs | 2 +- .../Tests/BasicGrainTests.cs | 35 ++++++++++--------- .../Tests/DIGrainTests.cs | 22 ++++++------ .../Tests/DeactivationGrainTests.cs | 4 +-- .../Tests/GrainProbeTests.cs | 20 +++++------ .../OrleansTestKit.Tests/Tests/LoggerTests.cs | 11 +++--- .../Tests/ReminderTests.cs | 14 ++++---- .../Tests/ServiceProbeTests.cs | 6 ++-- .../Tests/StorageTests.cs | 4 +-- .../OrleansTestKit.Tests/Tests/StreamTests.cs | 26 +++++++------- .../Tests/StrictGrainProbeTests.cs | 14 ++++---- .../Tests/StrictStreamTests.cs | 18 +++++----- test/OrleansTestKit.Tests/Tests/TimerTests.cs | 15 ++++---- 17 files changed, 122 insertions(+), 120 deletions(-) diff --git a/src/OrleansTestKit/OrleansTestKit.csproj b/src/OrleansTestKit/OrleansTestKit.csproj index 76e0995..9179327 100644 --- a/src/OrleansTestKit/OrleansTestKit.csproj +++ b/src/OrleansTestKit/OrleansTestKit.csproj @@ -7,8 +7,8 @@ OrleansContrib OrleansTestKit A testing framework for Microsoft Orleans that does not use a real silo - Copyright © 2017 - 2.0.0 + Copyright © 2018 + 2.1.0 diff --git a/src/OrleansTestKit/TestGrainLifecycle.cs b/src/OrleansTestKit/TestGrainLifecycle.cs index 60bbeb1..68e0512 100644 --- a/src/OrleansTestKit/TestGrainLifecycle.cs +++ b/src/OrleansTestKit/TestGrainLifecycle.cs @@ -24,18 +24,16 @@ public IDisposable Subscribe(string observerName, int stage, ILifecycleObserver }); } - public void TriggerStart() + public Task TriggerStartAsync() { var tasks = observers.OrderBy(x => x.Item1).Select(x => x.Item2.OnStart(CancellationToken.None)); - - Task.WaitAll(tasks.ToArray(), 1000); + return Task.WhenAll(tasks.ToArray()); } - public void TriggerStop() + public Task TriggerStopAsync() { var tasks = observers.Select(x => x.Item2.OnStop(CancellationToken.None)); - - Task.WaitAll(tasks.ToArray(), 1000); + return Task.WhenAll(tasks.ToArray()); } } } diff --git a/src/OrleansTestKit/TestKitSilo.cs b/src/OrleansTestKit/TestKitSilo.cs index 73b18f6..9fb3ed8 100644 --- a/src/OrleansTestKit/TestKitSilo.cs +++ b/src/OrleansTestKit/TestKitSilo.cs @@ -92,24 +92,23 @@ public TestKitSilo() _grainCreator = new TestGrainCreator(_grainRuntime, ServiceProvider); } - #region CreateGrains + #region CreateGrains + public Task CreateGrainAsync(long id) where T : Grain, IGrainWithIntegerKey + => CreateGrainAsync(new TestGrainIdentity(id)); - public T CreateGrain(long id) where T : Grain, IGrainWithIntegerKey - => CreateGrain(new TestGrainIdentity(id)); + public Task CreateGrainAsync(Guid id) where T : Grain, IGrainWithGuidKey + => CreateGrainAsync(new TestGrainIdentity(id)); - public T CreateGrain(Guid id) where T : Grain, IGrainWithGuidKey - => CreateGrain(new TestGrainIdentity(id)); + public Task CreateGrainAsync(string id) where T : Grain, IGrainWithStringKey + => CreateGrainAsync(new TestGrainIdentity(id)); - public T CreateGrain(string id) where T : Grain, IGrainWithStringKey - => CreateGrain(new TestGrainIdentity(id)); + public Task CreateGrainAsync(Guid id, string keyExtension) where T : Grain, IGrainWithGuidCompoundKey + => CreateGrainAsync(new TestGrainIdentity(id, keyExtension)); - public T CreateGrain(Guid id, string keyExtension) where T : Grain, IGrainWithGuidCompoundKey - => CreateGrain(new TestGrainIdentity(id, keyExtension)); + public Task CreateGrainAsync(long id, string keyExtension) where T : Grain, IGrainWithIntegerCompoundKey + => CreateGrainAsync(new TestGrainIdentity(id, keyExtension)); - public T CreateGrain(long id, string keyExtension) where T : Grain, IGrainWithIntegerCompoundKey - => CreateGrain(new TestGrainIdentity(id, keyExtension)); - - private T CreateGrain(IGrainIdentity identity) where T : Grain + private async Task CreateGrainAsync(IGrainIdentity identity) where T : Grain { if (_isGrainCreated) throw new Exception( @@ -141,12 +140,11 @@ private T CreateGrain(IGrainIdentity identity) where T : Grain ReminderRegistry.SetGrainTarget(remindable); //Trigger the lifecycle hook that will get the grain's state from the runtime - _grainLifecycle.TriggerStart(); + await _grainLifecycle.TriggerStartAsync(); return grain as T; } - - #endregion CreateGrains + #endregion #region Verifies @@ -161,9 +159,9 @@ public void VerifyRuntime(Expression> expression, Func /// /// Grain to Deactivate - public void Deactivate(Grain grain) + public Task DeactivateAsync(Grain grain) { - _grainLifecycle.TriggerStop(); + return _grainLifecycle.TriggerStopAsync(); } } } diff --git a/test/OrleansTestKit.Tests/Grains/StatefulActivationGrain.cs b/test/OrleansTestKit.Tests/Grains/StatefulActivationGrain.cs index ff02c57..1d0a4a0 100644 --- a/test/OrleansTestKit.Tests/Grains/StatefulActivationGrain.cs +++ b/test/OrleansTestKit.Tests/Grains/StatefulActivationGrain.cs @@ -15,9 +15,10 @@ public sealed class StatefulActivationGrain : Grain GetStateValue() => Task.FromResult(State.Value); diff --git a/test/OrleansTestKit.Tests/Tests/ActivationGrainTests.cs b/test/OrleansTestKit.Tests/Tests/ActivationGrainTests.cs index 77691b0..f34a55a 100644 --- a/test/OrleansTestKit.Tests/Tests/ActivationGrainTests.cs +++ b/test/OrleansTestKit.Tests/Tests/ActivationGrainTests.cs @@ -15,7 +15,7 @@ public async Task ShouldActivateWithValidState() // Act - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); var value = await grain.GetActivationValue(); // Assert diff --git a/test/OrleansTestKit.Tests/Tests/BasicGrainTests.cs b/test/OrleansTestKit.Tests/Tests/BasicGrainTests.cs index 03d86c1..a26fcd0 100644 --- a/test/OrleansTestKit.Tests/Tests/BasicGrainTests.cs +++ b/test/OrleansTestKit.Tests/Tests/BasicGrainTests.cs @@ -15,7 +15,7 @@ public async Task SiloSayHelloTest() long id = new Random().Next(); const string greeting = "Bonjour"; - IHello grain = Silo.CreateGrain(id); + IHello grain = await Silo.CreateGrainAsync(id); // This will create and call a Hello grain with specified 'id' in one of the test silos. string reply = await grain.SayHello(greeting); @@ -25,29 +25,30 @@ public async Task SiloSayHelloTest() } [Fact] - public void GrainActivation() + public async Task GrainActivation() { - var grain = Silo.CreateGrain(new Random().Next()); + var grain = await Silo.CreateGrainAsync(new Random().Next()); grain.ActivateCount.Should().Be(1); } [Fact] - public void SecondGrainCreated() + public async Task SecondGrainCreated() { - Silo.CreateGrain(new Random().Next()); + await Silo.CreateGrainAsync(new Random().Next()); - Silo.Invoking(s => s.CreateGrain(new Random().Next())).ShouldThrow(); + Func creatingSecondGrainAsync = async () => await Silo.CreateGrainAsync(new Random().Next()); + creatingSecondGrainAsync.ShouldThrow(); } [Fact] - public void GrainDeactivation() + public async Task GrainDeactivation() { - var grain = Silo.CreateGrain(new Random().Next()); + var grain = await Silo.CreateGrainAsync(new Random().Next()); grain.DeactivateCount.Should().Be(0); - Silo.Deactivate(grain); + await Silo.DeactivateAsync(grain); grain.DeactivateCount.Should().Be(1); } @@ -57,7 +58,7 @@ public async Task IntegerKeyGrain() { const int id = int.MaxValue; - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); var key = await grain.GetKey(); @@ -70,7 +71,7 @@ public async Task IntegerCompoundKeyGrain() const int id = int.MaxValue; var ext = "Thing"; - var grain = Silo.CreateGrain(id, ext); + var grain = await Silo.CreateGrainAsync(id, ext); var key = await grain.GetKey(); @@ -83,7 +84,7 @@ public async Task GuidKeyGrain() { var id = Guid.NewGuid(); - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); var key = await grain.GetKey(); @@ -96,7 +97,7 @@ public async Task GuidCompoundKeyGrain() var id = Guid.NewGuid(); var ext = "Thing"; - var grain = Silo.CreateGrain(id, ext); + var grain = await Silo.CreateGrainAsync(id, ext); var key = await grain.GetKey(); @@ -109,7 +110,7 @@ public async Task StringKeyGrain() { const string id = "TestId"; - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); var key = await grain.GetKey(); @@ -121,7 +122,7 @@ public async Task StatefulIntegerKeyGrain() { const int id = int.MaxValue; - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); var key = await grain.GetKey(); @@ -133,7 +134,7 @@ public async Task StatefulGuidKeyGrain() { var id = Guid.NewGuid(); - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); var key = await grain.GetKey(); @@ -145,7 +146,7 @@ public async Task StatefulStringKeyGrain() { const string id = "TestId"; - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); var key = await grain.GetKey(); diff --git a/test/OrleansTestKit.Tests/Tests/DIGrainTests.cs b/test/OrleansTestKit.Tests/Tests/DIGrainTests.cs index ff3fdbe..52dbf33 100644 --- a/test/OrleansTestKit.Tests/Tests/DIGrainTests.cs +++ b/test/OrleansTestKit.Tests/Tests/DIGrainTests.cs @@ -1,7 +1,7 @@ using System; using System.Threading.Tasks; using FluentAssertions; -using Moq; +using Moq; using TestGrains; using TestInterfaces; using Xunit; @@ -11,24 +11,26 @@ namespace Orleans.TestKit.Tests public class DIGrainTests : TestKitBase { [Fact] - public void CreateGrainWithService() + public async Task CreateGrainWithService() { - var grain = Silo.CreateGrain(Guid.NewGuid()); + var grain = await Silo.CreateGrainAsync(Guid.NewGuid()); grain.Service.Should().NotBeNull(); - } - + } + + + [Fact] - public void SetupGrainService() + public async Task SetupGrainService() { var mockSvc = new Mock(); mockSvc.Setup(x => x.GetValue()).Returns(true); Silo.ServiceProvider.AddServiceProbe(mockSvc); - var grain = Silo.CreateGrain(Guid.NewGuid()); + var grain = await Silo.CreateGrainAsync(Guid.NewGuid()); grain.GetServiceValue().Should().BeTrue(); mockSvc.Verify(x => x.GetValue(), Times.Once); - } - } -} + } + } +} diff --git a/test/OrleansTestKit.Tests/Tests/DeactivationGrainTests.cs b/test/OrleansTestKit.Tests/Tests/DeactivationGrainTests.cs index 41e1087..91828f4 100644 --- a/test/OrleansTestKit.Tests/Tests/DeactivationGrainTests.cs +++ b/test/OrleansTestKit.Tests/Tests/DeactivationGrainTests.cs @@ -12,7 +12,7 @@ public class DeactivationGrainTests : TestKitBase public async Task ShouldCallDeactivateOnIdle() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); // Act await grain.DeactivateOnIdle(); @@ -25,7 +25,7 @@ public async Task ShouldCallDeactivateOnIdle() public async Task ShouldCallDelayDeactivation() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); var timeSpan = TimeSpan.FromSeconds(5); // Act diff --git a/test/OrleansTestKit.Tests/Tests/GrainProbeTests.cs b/test/OrleansTestKit.Tests/Tests/GrainProbeTests.cs index 0783250..0bbc2d2 100644 --- a/test/OrleansTestKit.Tests/Tests/GrainProbeTests.cs +++ b/test/OrleansTestKit.Tests/Tests/GrainProbeTests.cs @@ -14,7 +14,7 @@ public class GrainProbeTests : TestKitBase [Fact] public async Task SetupProbe() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); var pong = Silo.AddProbe(22); @@ -26,7 +26,7 @@ public async Task SetupProbe() [Fact] public async Task SetupCompoundProbe() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); var pong = Silo.AddProbe(44, keyExtension: "Test"); @@ -36,18 +36,18 @@ public async Task SetupCompoundProbe() } [Fact] - public void MissingProbe() + public async Task MissingProbe() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); //There should not be an exception, since we are using loose grain generation grain.Invoking(p => p.Ping()).ShouldNotThrow(); } [Fact] - public void InvalidProbe() + public async Task InvalidProbe() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); //This uses the wrong id for the IPong since this is hard coded within PingGrain var pong = Silo.AddProbe(0); @@ -58,9 +58,9 @@ public void InvalidProbe() } [Fact] - public void InvalidProbeType() + public async Task InvalidProbeType() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); //This correct id, but a different grain type var pong = Silo.AddProbe(22); @@ -135,7 +135,7 @@ public async Task FactoryProbe() this.Silo.AddProbe(identity => pong); - var grain = this.Silo.CreateGrain(1); + var grain = await this.Silo.CreateGrainAsync(1); await grain.Ping(); @@ -148,7 +148,7 @@ public async Task ProbeWithClassPrefix() Silo.AddProbe("Android", "TestGrains.DeviceAndroidGrain"); Silo.AddProbe("IOS", "TestGrains.DeviceIosGrain"); - var managerGrain = this.Silo.CreateGrain(0); + var managerGrain = await this.Silo.CreateGrainAsync(0); var iosGrain = await managerGrain.GetDeviceGrain("IOS"); var androidGrain = await managerGrain.GetDeviceGrain("Android"); diff --git a/test/OrleansTestKit.Tests/Tests/LoggerTests.cs b/test/OrleansTestKit.Tests/Tests/LoggerTests.cs index 3b47fb9..9ae9f15 100644 --- a/test/OrleansTestKit.Tests/Tests/LoggerTests.cs +++ b/test/OrleansTestKit.Tests/Tests/LoggerTests.cs @@ -1,4 +1,5 @@ -using FluentAssertions; +using System.Threading.Tasks; +using FluentAssertions; using TestGrains; using TestInterfaces; using Xunit; @@ -16,21 +17,21 @@ public LoggerTests(ITestOutputHelper output) } [Fact] - public void ConsoleLog() + public async Task ConsoleLog() { const string greeting = "Bonjour"; - IHello grain = Silo.CreateGrain(1); + IHello grain = await Silo.CreateGrainAsync(1); grain.Invoking(g => g.SayHello(greeting)).ShouldNotThrow(); } [Fact] - public void XUnitLog() + public async Task XUnitLog() { const string greeting = "Bonjour"; - IHello grain = Silo.CreateGrain(2); + IHello grain = await Silo.CreateGrainAsync(2); grain.Invoking(g => g.SayHello(greeting)).ShouldNotThrow(); } diff --git a/test/OrleansTestKit.Tests/Tests/ReminderTests.cs b/test/OrleansTestKit.Tests/Tests/ReminderTests.cs index e094b52..f0a4260 100644 --- a/test/OrleansTestKit.Tests/Tests/ReminderTests.cs +++ b/test/OrleansTestKit.Tests/Tests/ReminderTests.cs @@ -15,7 +15,7 @@ public class ReminderTests : TestKitBase public async Task RegisterReminder() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); const string reminderName = "abc123"; var due = TimeSpan.Zero; @@ -32,7 +32,7 @@ public async Task RegisterReminder() public async Task UnRegisterReminder() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); const string reminderName = "abc123"; var due = TimeSpan.Zero; @@ -50,7 +50,7 @@ public async Task UnRegisterReminder() public async Task TriggerUnRegisterReminder() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); const string reminderName = "abc123"; var due = TimeSpan.Zero; @@ -69,7 +69,7 @@ public async Task TriggerUnRegisterReminder() public async Task TriggerAllReminders() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); const string reminderName1 = "abc123"; const string reminderName2 = "123"; @@ -90,7 +90,7 @@ public async Task TriggerAllReminders() public async Task TriggerSingleReminderOnce() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); const string reminderName = "abc123"; @@ -108,7 +108,7 @@ public async Task TriggerSingleReminderOnce() public async Task TriggerSingleReminderMultiple() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); const string reminderName = "abc123"; @@ -127,7 +127,7 @@ public async Task TriggerSingleReminderMultiple() public async Task TriggerUnknownReminder() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); await grain.RegisterReminder("a", TimeSpan.Zero, TimeSpan.MaxValue); diff --git a/test/OrleansTestKit.Tests/Tests/ServiceProbeTests.cs b/test/OrleansTestKit.Tests/Tests/ServiceProbeTests.cs index aab43d4..708cd2a 100644 --- a/test/OrleansTestKit.Tests/Tests/ServiceProbeTests.cs +++ b/test/OrleansTestKit.Tests/Tests/ServiceProbeTests.cs @@ -21,7 +21,7 @@ public async Task SayHelloTestShouldPrintDate() dateServiceMock.Setup(i => i.GetCurrentDate()) .ReturnsAsync(() => date); - var grain = Silo.CreateGrain(10); + var grain = await Silo.CreateGrainAsync(10); // Act var reply = await grain.SayHello(greeting); @@ -39,7 +39,7 @@ public async Task SayHelloTestShouldPrintDefaultDateWhenServiceProbeNotDefined() // Arrange const string greeting = "Bonjour"; - var grain = Silo.CreateGrain(10); + var grain = await Silo.CreateGrainAsync(10); // Act var reply = await grain.SayHello(greeting); @@ -62,7 +62,7 @@ public async Task SayHelloTestShouldPrintDateWhenServiceProvided() Silo.AddService(dateServiceMock.Object); - var grain = Silo.CreateGrain(10); + var grain = await Silo.CreateGrainAsync(10); // Act var reply = await grain.SayHello(greeting); diff --git a/test/OrleansTestKit.Tests/Tests/StorageTests.cs b/test/OrleansTestKit.Tests/Tests/StorageTests.cs index 0836c39..73ef51d 100644 --- a/test/OrleansTestKit.Tests/Tests/StorageTests.cs +++ b/test/OrleansTestKit.Tests/Tests/StorageTests.cs @@ -17,7 +17,7 @@ public async Task SiloSayHelloArchiveTest() const string greeting1 = "Bonjour"; const string greeting2 = "Hei"; - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); // This will directly call the grain under test. await grain.SayHello(greeting1); @@ -38,7 +38,7 @@ public async Task SiloSayHelloResetStorageCountsTest() long id = new Random().Next(); const string greeting = "Bonjour"; - var grain = Silo.CreateGrain(id); + var grain = await Silo.CreateGrainAsync(id); // This will directly call the grain under test. await grain.SayHello(greeting); diff --git a/test/OrleansTestKit.Tests/Tests/StreamTests.cs b/test/OrleansTestKit.Tests/Tests/StreamTests.cs index 1ee0f57..95c92e8 100644 --- a/test/OrleansTestKit.Tests/Tests/StreamTests.cs +++ b/test/OrleansTestKit.Tests/Tests/StreamTests.cs @@ -12,7 +12,7 @@ public class StreamTests : TestKitBase [Fact] public async Task GrainSentMessages() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); var stream = Silo.AddStreamProbe(Guid.Empty, null); @@ -25,9 +25,9 @@ public async Task GrainSentMessages() } [Fact] - public void LazyStreamProvider() + public async Task LazyStreamProvider() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); const string msg = "Hello Chat"; @@ -36,11 +36,11 @@ public void LazyStreamProvider() } [Fact] - public void LazyStreamProviderStrict() + public async Task LazyStreamProviderStrict() { Silo.Options.StrictStreamProbes = true; - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); const string msg = "Hello Chat"; @@ -51,7 +51,7 @@ public void LazyStreamProviderStrict() [Fact] public async Task IncorrectVerifyMessage() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); var stream = Silo.AddStreamProbe(Guid.Empty, null); @@ -63,9 +63,9 @@ public async Task IncorrectVerifyMessage() } [Fact] - public void IncorrectProbeId() + public async Task IncorrectProbeId() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); Silo.AddStreamProbe(Guid.NewGuid(), null); @@ -75,9 +75,9 @@ public void IncorrectProbeId() } [Fact] - public void IncorrectProbeNamespace() + public async Task IncorrectProbeNamespace() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); Silo.AddStreamProbe(Guid.Empty, "Wrong"); @@ -87,11 +87,11 @@ public void IncorrectProbeNamespace() } [Fact] - public void GrainIsSubscribed() + public async Task GrainIsSubscribed() { var stream = Silo.AddStreamProbe(Guid.Empty, null); - Silo.CreateGrain(1); + await Silo.CreateGrainAsync(1); stream.Subscribed.Should().Be(1); } @@ -101,7 +101,7 @@ public async Task GrainReceives() { var stream = Silo.AddStreamProbe(Guid.Empty, null); - var grain = Silo.CreateGrain(1); + var grain = await Silo.CreateGrainAsync(1); await stream.OnNextAsync(new ChatMessage("Ding")); diff --git a/test/OrleansTestKit.Tests/Tests/StrictGrainProbeTests.cs b/test/OrleansTestKit.Tests/Tests/StrictGrainProbeTests.cs index 104fb49..3f0493b 100644 --- a/test/OrleansTestKit.Tests/Tests/StrictGrainProbeTests.cs +++ b/test/OrleansTestKit.Tests/Tests/StrictGrainProbeTests.cs @@ -20,7 +20,7 @@ public StrictGrainProbeTests() [Fact] public async Task SetupProbe() { - var grain = Silo.CreateGrain(1); + var grain = await Silo.CreateGrainAsync(1); var pong = Silo.AddProbe(22); @@ -30,17 +30,17 @@ public async Task SetupProbe() } [Fact] - public void MissingProbe() + public async Task MissingProbe() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); grain.Invoking(p => p.Ping()).ShouldThrowExactly(); } [Fact] - public void InvalidProbe() + public async Task InvalidProbe() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); //This uses the wrong id for the IPong since this is hard coded within PingGrain var pong = Silo.AddProbe(0); @@ -51,9 +51,9 @@ public void InvalidProbe() } [Fact] - public void InvalidProbeType() + public async Task InvalidProbeType() { - IPing grain = Silo.CreateGrain(1); + IPing grain = await Silo.CreateGrainAsync(1); //This uses the correct id, but the wrong grain type var pong = Silo.AddProbe(22); diff --git a/test/OrleansTestKit.Tests/Tests/StrictStreamTests.cs b/test/OrleansTestKit.Tests/Tests/StrictStreamTests.cs index 3229ea3..b6f1db4 100644 --- a/test/OrleansTestKit.Tests/Tests/StrictStreamTests.cs +++ b/test/OrleansTestKit.Tests/Tests/StrictStreamTests.cs @@ -17,7 +17,7 @@ public StrictStreamTests() [Fact] public async Task GrainSentMessages() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); var stream = Silo.AddStreamProbe(Guid.Empty, null); @@ -32,7 +32,7 @@ public async Task GrainSentMessages() [Fact] public async Task IncorrectVerifyMessage() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); var stream = Silo.AddStreamProbe(Guid.Empty, null); @@ -44,9 +44,9 @@ public async Task IncorrectVerifyMessage() } [Fact] - public void IncorrectProbeId() + public async Task IncorrectProbeId() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); Silo.AddStreamProbe(Guid.NewGuid(), null); @@ -56,9 +56,9 @@ public void IncorrectProbeId() } [Fact] - public void IncorrectProbeNamespace() + public async Task IncorrectProbeNamespace() { - var chatty = Silo.CreateGrain(4); + var chatty = await Silo.CreateGrainAsync(4); Silo.AddStreamProbe(Guid.Empty, "Wrong"); @@ -68,11 +68,11 @@ public void IncorrectProbeNamespace() } [Fact] - public void GrainIsSubscribed() + public async Task GrainIsSubscribed() { var stream = Silo.AddStreamProbe(Guid.Empty, null); - Silo.CreateGrain(1); + await Silo.CreateGrainAsync(1); stream.Subscribed.Should().Be(1); } @@ -82,7 +82,7 @@ public async Task GrainReceives() { var stream = Silo.AddStreamProbe(Guid.Empty, null); - var grain = Silo.CreateGrain(1); + var grain = await Silo.CreateGrainAsync(1); await stream.OnNextAsync(new ChatMessage("Ding")); diff --git a/test/OrleansTestKit.Tests/Tests/TimerTests.cs b/test/OrleansTestKit.Tests/Tests/TimerTests.cs index 8c74030..aef2b88 100644 --- a/test/OrleansTestKit.Tests/Tests/TimerTests.cs +++ b/test/OrleansTestKit.Tests/Tests/TimerTests.cs @@ -1,4 +1,5 @@ -using FluentAssertions; +using System.Threading.Tasks; +using FluentAssertions; using Orleans.TestKit.Storage; using Orleans.TestKit.Timers; using TestGrains; @@ -9,10 +10,10 @@ namespace Orleans.TestKit.Tests public class TimerTests : TestKitBase { [Fact] - public void ShouldFireAllTimers() + public async Task ShouldFireAllTimers() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); // Act Silo.FireAllTimers(); @@ -24,10 +25,10 @@ public void ShouldFireAllTimers() } [Fact] - public void ShouldFireFirstTimer() + public async Task ShouldFireFirstTimer() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); // Act Silo.FireTimer(0); @@ -39,10 +40,10 @@ public void ShouldFireFirstTimer() } [Fact] - public void ShouldFireSecondTimer() + public async Task ShouldFireSecondTimer() { // Arrange - var grain = Silo.CreateGrain(0); + var grain = await Silo.CreateGrainAsync(0); // Act Silo.FireTimer(1);