Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add test case Int64StronglyTypedId_FromRoute_Should_Work_Test #29

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions test/NetCorePal.Web.UnitTests/ProgramTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,17 @@ public async Task SetPaidTest()
Assert.NotNull(rd);
Assert.True(rd.Success);
}

[Fact] public async Task Int64StronglyTypedId_FromRoute_Should_Work_Test()
{
int id = Random.Shared.Next();
var client = factory.CreateClient();
var response = await client.GetAsync($"/path/{id}");
Assert.True(response.IsSuccessStatusCode);
var data = await response.Content.ReadFromJsonAsync<ResponseData<OrderId>>(JsonOption);
Assert.NotNull(data);
Assert.True(data.Success);
Assert.Equal(id, data.Data.Id);
}
}
}
8 changes: 8 additions & 0 deletions test/NetCorePal.Web/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@
{
throw new Exception("系统异常");
}


[HttpGet]
[Route("/path/{id}")]
public Task<ResponseData<OrderId>> Path([FromRoute] OrderId id)

Check warning on line 167 in test/NetCorePal.Web/Controllers/OrderController.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'OrderController.Path(OrderId)'

Check warning on line 167 in test/NetCorePal.Web/Controllers/OrderController.cs

View workflow job for this annotation

GitHub Actions / build

Missing XML comment for publicly visible type or member 'OrderController.Path(OrderId)'
{
return Task.FromResult(new ResponseData<OrderId>(id));
}

}
}
Loading