From 52f158294c16510dfd14101c3980645da05c3790 Mon Sep 17 00:00:00 2001 From: paule96 Date: Wed, 28 Aug 2024 15:09:57 +0000 Subject: [PATCH] add a test that checks excatly the behavior Signed-off-by: paule96 --- .../ISerializationActor.cs | 2 +- .../Actors/SerializationActor.cs | 4 +-- .../Actors/E2ETests.CustomSerializerTests.cs | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/test/Dapr.E2E.Test.Actors/ISerializationActor.cs b/test/Dapr.E2E.Test.Actors/ISerializationActor.cs index 200707ec0..46455c28d 100644 --- a/test/Dapr.E2E.Test.Actors/ISerializationActor.cs +++ b/test/Dapr.E2E.Test.Actors/ISerializationActor.cs @@ -11,7 +11,7 @@ namespace Dapr.E2E.Test.Actors public interface ISerializationActor : IActor, IPingActor { Task SendAsync(string name, SerializationPayload payload, CancellationToken cancellationToken = default); - Task AnotherMethod(); + Task AnotherMethod(DateTime payload); } public record SerializationPayload(string Message) diff --git a/test/Dapr.E2E.Test.App/Actors/SerializationActor.cs b/test/Dapr.E2E.Test.App/Actors/SerializationActor.cs index 95f3f8111..09e650fae 100644 --- a/test/Dapr.E2E.Test.App/Actors/SerializationActor.cs +++ b/test/Dapr.E2E.Test.App/Actors/SerializationActor.cs @@ -24,8 +24,8 @@ public Task SendAsync(string name, return Task.FromResult(payload); } - public Task AnotherMethod(){ - return Task.FromResult(DateTime.UtcNow); + public Task AnotherMethod(DateTime payload){ + return Task.FromResult(payload); } } } diff --git a/test/Dapr.E2E.Test/Actors/E2ETests.CustomSerializerTests.cs b/test/Dapr.E2E.Test/Actors/E2ETests.CustomSerializerTests.cs index c393f2ef1..5a20fff3d 100644 --- a/test/Dapr.E2E.Test/Actors/E2ETests.CustomSerializerTests.cs +++ b/test/Dapr.E2E.Test/Actors/E2ETests.CustomSerializerTests.cs @@ -84,5 +84,32 @@ public async Task ActorCanSupportCustomSerializer() Assert.Equal(JsonSerializer.Serialize(kvp.Value), JsonSerializer.Serialize(value)); } } + + /// + /// This was actually a problem that is why the test exists. + /// It just checks, if the interface of the actor has more than one method defined, + /// that if can call it and serialize the payload correctly. + /// + /// + /// More than one methods means here, that in the exact interface must be two methods defined. + /// That excludes hirachies. + /// So wouldn't count here, because it's not directly defined in + /// . (it's defined in the base of it.) + /// That why was created, + /// so there are now more then one method. + /// + [Fact] + public async Task ActorCanSupportCustomSerializerAndCallMoreThenOneDefinedMethod() + { + using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60)); + var proxy = this.ProxyFactory.CreateActorProxy(ActorId.CreateRandom(), "SerializationActor"); + + await ActorRuntimeChecker.WaitForActorRuntimeAsync(this.AppId, this.Output, proxy, cts.Token); + + var payload = DateTime.MinValue; + var result = await proxy.AnotherMethod(payload); + + Assert.Equal(payload, result); + } } }