Skip to content

Commit

Permalink
Merge branch 'release/v0.4.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
jirenius committed Oct 18, 2021
2 parents 00a805c + d77c4aa commit d9728c8
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
36 changes: 36 additions & 0 deletions ResgateIO.Service.UnitTests/QueryEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,42 @@ public void QueryRequest_UsingWith_SendsCorrectResponse(string query, Action<IQu
}
}

[Theory]
[MemberData(nameof(GetQueryRequestTestData))]
public void QueryRequest_UsingAsyncCallback_SendsCorrectResponse(string query, Action<IQueryRequest> callback, object expected)
{
Service.AddHandler("model", new DynamicHandler().Call(r =>
{
r.QueryEvent(async qreq => {
await Task.Run(() =>callback(qreq));
});
r.Ok();
}));
Service.Serve(Conn);
Conn.GetMsg().AssertSubject("system.reset");
string inbox = Conn.NATSRequest("call.test.model.method", new RequestDto { CID = Test.CID, Token = Test.Token, Params = new { query } });
Assert.True(Conn.GetMsg()
.AssertSubject("event.test.model.query")
.TryGetPath("subject", out JToken subject), "no subject property in query event");
Conn.GetMsg()
.AssertSubject(inbox)
.AssertResult(null);
string inboxQR = Conn.NATSRequest((string)subject, new { query });
var msg = Conn.GetMsg().AssertSubject(inboxQR);
if (expected is string expectedString)
{
msg.AssertError(expectedString);
}
else if (expected is ResError expectedError)
{
msg.AssertError(expectedError);
}
else
{
msg.AssertResult(expected);
}
}

[Fact]
public void QueryRequest_CallingTimeoutWithTimespan_SendsPreresponse()
{
Expand Down
4 changes: 2 additions & 2 deletions ResgateIO.Service/QueryEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private void onMessage(object sender, MsgHandlerEventArgs e)

Service.Log.Trace("Q=> {0}: {1}", subj, Encoding.UTF8.GetString(msg.Data));

Resource.Service.With(Resource, () =>
Resource.Service.With(Resource, async () =>
{
if (callback == null)
{
Expand Down Expand Up @@ -102,7 +102,7 @@ private void onMessage(object sender, MsgHandlerEventArgs e)

try
{
callback(qr);
await callback(qr);
}
catch(ResException ex)
{
Expand Down
4 changes: 2 additions & 2 deletions ResgateIO.Service/ResgateIO.Service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<PropertyGroup>
<TargetFrameworks>netstandard1.6;netstandard2.0;net45</TargetFrameworks>
<PackageId>ResgateIO.Service</PackageId>
<Version>0.4.6</Version>
<Version>0.4.7</Version>
<Title>RES Service .NET library</Title>
<Authors>Samuel Jirenius</Authors>
<Owners>Samuel Jirenius</Owners>
<Company>Resgate.io</Company>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageProjectUrl>https://resgate.io/</PackageProjectUrl>
<Description>RES service library for building next gen realtime APIs with synchronized clients using Resgate.</Description>
<PackageReleaseNotes>https://github.com/jirenius/csharp-res/releases/tag/v0.4.6</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/jirenius/csharp-res/releases/tag/v0.4.7</PackageReleaseNotes>
<Copyright>Copyright 2019 Samuel Jirenius</Copyright>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/jirenius/csharp-res</RepositoryUrl>
Expand Down

0 comments on commit d9728c8

Please sign in to comment.