Skip to content

Commit

Permalink
Merge pull request #29 from netcorepal/dev
Browse files Browse the repository at this point in the history
add test case Int64StronglyTypedId_FromRoute_Should_Work_Test
  • Loading branch information
witskeeper authored May 12, 2024
2 parents 2e121f1 + c8578f4 commit 9fb5cd5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
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 @@ public Task<ResponseData<long>> BadRequest(long id)
{
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)'

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));
}

}
}

0 comments on commit 9fb5cd5

Please sign in to comment.