Skip to content

Commit

Permalink
add a test that checks excatly the behavior
Browse files Browse the repository at this point in the history
Signed-off-by: paule96 <[email protected]>
  • Loading branch information
paule96 committed Aug 28, 2024
1 parent 8287b4a commit 52f1582
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/Dapr.E2E.Test.Actors/ISerializationActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Dapr.E2E.Test.Actors
public interface ISerializationActor : IActor, IPingActor
{
Task<SerializationPayload> SendAsync(string name, SerializationPayload payload, CancellationToken cancellationToken = default);
Task<DateTime> AnotherMethod();
Task<DateTime> AnotherMethod(DateTime payload);
}

public record SerializationPayload(string Message)
Expand Down
4 changes: 2 additions & 2 deletions test/Dapr.E2E.Test.App/Actors/SerializationActor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public Task<SerializationPayload> SendAsync(string name,
return Task.FromResult(payload);
}

public Task<DateTime> AnotherMethod(){
return Task.FromResult(DateTime.UtcNow);
public Task<DateTime> AnotherMethod(DateTime payload){
return Task.FromResult(payload);
}
}
}
27 changes: 27 additions & 0 deletions test/Dapr.E2E.Test/Actors/E2ETests.CustomSerializerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,32 @@ public async Task ActorCanSupportCustomSerializer()
Assert.Equal(JsonSerializer.Serialize(kvp.Value), JsonSerializer.Serialize(value));
}
}

/// <summary>
/// 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.
/// </summary>
/// <remarks>
/// More than one methods means here, that in the exact interface must be two methods defined.
/// That excludes hirachies.
/// So <see cref="IPingActor.Ping"/> wouldn't count here, because it's not directly defined in
/// <see cref="ISerializationActor"/>. (it's defined in the base of it.)
/// That why <see cref="ISerializationActor.AnotherMethod(DateTime)"/> was created,
/// so there are now more then one method.
/// </remark>
[Fact]
public async Task ActorCanSupportCustomSerializerAndCallMoreThenOneDefinedMethod()
{
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(60));
var proxy = this.ProxyFactory.CreateActorProxy<ISerializationActor>(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);
}
}
}

0 comments on commit 52f1582

Please sign in to comment.