Skip to content

Commit ee581a1

Browse files
committed
add a test that checks excatly the behavior
Signed-off-by: paule96 <[email protected]>
1 parent 8db5840 commit ee581a1

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

test/Dapr.E2E.Test.Actors/ISerializationActor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace Dapr.E2E.Test.Actors
1111
public interface ISerializationActor : IActor, IPingActor
1212
{
1313
Task<SerializationPayload> SendAsync(string name, SerializationPayload payload, CancellationToken cancellationToken = default);
14-
Task<DateTime> AnotherMethod();
14+
Task<DateTime> AnotherMethod(DateTime payload);
1515
}
1616

1717
public record SerializationPayload(string Message)

test/Dapr.E2E.Test.App/Actors/SerializationActor.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public Task<SerializationPayload> SendAsync(string name,
2424
return Task.FromResult(payload);
2525
}
2626

27-
public Task<DateTime> AnotherMethod(){
28-
return Task.FromResult(DateTime.UtcNow);
27+
public Task<DateTime> AnotherMethod(DateTime payload){
28+
return Task.FromResult(payload);
2929
}
3030
}
3131
}

test/Dapr.E2E.Test/Actors/E2ETests.CustomSerializerTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,32 @@ public async Task ActorCanSupportCustomSerializer()
8484
Assert.Equal(JsonSerializer.Serialize(kvp.Value), JsonSerializer.Serialize(value));
8585
}
8686
}
87+
88+
/// <summary>
89+
/// This was actually a problem that is why the test exists.
90+
/// It just checks, if the interface of the actor has more than one method defined,
91+
/// that if can call it and serialize the payload correctly.
92+
/// </summary>
93+
/// <remarks>
94+
/// More than one methods means here, that in the exact interface must be two methods defined.
95+
/// That excludes hirachies.
96+
/// So <see cref="IPingActor.Ping"/> wouldn't count here, because it's not directly defined in
97+
/// <see cref="ISerializationActor"/>. (it's defined in the base of it.)
98+
/// That why <see cref="ISerializationActor.AnotherMethod(DateTime)"/> was created,
99+
/// so there are now more then one method.
100+
/// </remark>
101+
[Fact]
102+
public async Task ActorCanSupportCustomSerializerAndCallMoreThenOneDefinedMethod()
103+
{
104+
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
105+
var proxy = this.ProxyFactory.CreateActorProxy<ISerializationActor>(ActorId.CreateRandom(), "SerializationActor");
106+
107+
await ActorRuntimeChecker.WaitForActorRuntimeAsync(this.AppId, this.Output, proxy, cts.Token);
108+
109+
var payload = DateTime.MinValue;
110+
var result = await proxy.AnotherMethod(payload);
111+
112+
Assert.Equal(payload, result);
113+
}
87114
}
88115
}

0 commit comments

Comments
 (0)