diff --git a/src/Dapr.Actors/Communication/ActorStateResponse.cs b/src/Dapr.Actors/Communication/ActorStateResponse.cs index f75da0626..22b3bf20e 100644 --- a/src/Dapr.Actors/Communication/ActorStateResponse.cs +++ b/src/Dapr.Actors/Communication/ActorStateResponse.cs @@ -18,7 +18,7 @@ namespace Dapr.Actors.Communication /// /// Represents a response from fetching an actor state key. /// - class ActorStateResponse + public class ActorStateResponse { /// /// Initializes a new instance of the class. diff --git a/test/Dapr.Actors.Test/TestDaprInteractor.cs b/test/Dapr.Actors.Test/TestDaprInteractor.cs index 92cfa7096..1bfd46e5e 100644 --- a/test/Dapr.Actors.Test/TestDaprInteractor.cs +++ b/test/Dapr.Actors.Test/TestDaprInteractor.cs @@ -81,7 +81,7 @@ public Task SaveStateTransactionallyAsync(string actorType, string actorId, stri /// Name of key to get value for. /// Cancels the operation. /// A task that represents the asynchronous operation. - public Task GetStateAsync(string actorType, string actorId, string keyName, CancellationToken cancellationToken = default) + public Task> GetStateAsync(string actorType, string actorId, string keyName, CancellationToken cancellationToken = default) { throw new System.NotImplementedException(); } diff --git a/test/Dapr.E2E.Test.Actors/Reminders/IReminderActor.cs b/test/Dapr.E2E.Test.Actors/Reminders/IReminderActor.cs index 0bf57f64c..c0e3f86a2 100644 --- a/test/Dapr.E2E.Test.Actors/Reminders/IReminderActor.cs +++ b/test/Dapr.E2E.Test.Actors/Reminders/IReminderActor.cs @@ -1,4 +1,4 @@ -// ------------------------------------------------------------------------ +// ------------------------------------------------------------------------ // Copyright 2021 The Dapr Authors // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/test/Dapr.E2E.Test.Actors/State/IStateActor.cs b/test/Dapr.E2E.Test.Actors/State/IStateActor.cs index e453f7fa3..f19122102 100644 --- a/test/Dapr.E2E.Test.Actors/State/IStateActor.cs +++ b/test/Dapr.E2E.Test.Actors/State/IStateActor.cs @@ -18,5 +18,9 @@ namespace Dapr.E2E.Test.Actors.State { public interface IStateActor : IPingActor, IActor - { } + { + Task GetState(string key); + + Task SetState(string key, string value, TimeSpan? ttl); + } } diff --git a/test/Dapr.E2E.Test.App/Actors/StateActor.cs b/test/Dapr.E2E.Test.App/Actors/StateActor.cs index 8468771ce..71a952e0f 100644 --- a/test/Dapr.E2E.Test.App/Actors/StateActor.cs +++ b/test/Dapr.E2E.Test.App/Actors/StateActor.cs @@ -18,21 +18,30 @@ namespace Dapr.E2E.Test.Actors.State { - public class StateActor : Actor + public class StateActor : Actor, IStateActor { public StateActor(ActorHost host) : base(host) { } + public Task Ping() + { + return Task.CompletedTask; + } + public Task GetState(string key) { return this.StateManager.GetStateAsync(key); } - public Task SetState(string key, string value, TimeSpan? ttl) + public Task SetState(string key, string value, TimeSpan? ttl) { - return this.StateManager.SetStateAsync(key, value, ttl: ttl); + if (ttl.HasValue) + { + return this.StateManager.SetStateAsync(key, value, ttl: ttl.Value); + } + return this.StateManager.SetStateAsync(key, value); } } } diff --git a/test/Dapr.E2E.Test/Actors/E2ETests.StateTests.cs b/test/Dapr.E2E.Test/Actors/E2ETests.StateTests.cs index 853acf944..735d1594a 100644 --- a/test/Dapr.E2E.Test/Actors/E2ETests.StateTests.cs +++ b/test/Dapr.E2E.Test/Actors/E2ETests.StateTests.cs @@ -30,15 +30,19 @@ public async Task ActorCanSaveStateWithTTL() await WaitForActorRuntimeAsync(proxy, cts.Token); - await proxy.SaveState("key", "value", 2, cts.Token); + await proxy.SetState("key", "value", TimeSpan.FromSeconds(2)); - state = await.proxy.GetState("key", cts.Token); - Assert.Equal("value", state.Value); + var resp = await proxy.GetState("key"); + Assert.Equal("value", resp); - await Task.Delay(TimeSpan.FromSeconds(2), cts.Token); + await Task.Delay(TimeSpan.FromSeconds(2)); - state = await.proxy.GetState("key", cts.Token); - Assert.Null(state.Value); + resp = await proxy.GetState("key"); + Assert.Null(resp); + + await proxy.SetState("key", "new-value", null); + resp = await proxy.GetState("key"); + Assert.Equal("new-value", resp); } } }