注釋在運行時工作正常,但我可以用單元測試來測試它嗎?我試著調試它,但似乎測試只是跳入,因為直接調用了該方法。測試:var result = (StatusCodeResult)await this.Sut.Values(1, null);result.StatusCode.Should().Be(HttpStatusCode.BadRequest);方法:public async Task<IActionResult> Values(int identifier, [Required] SomeType query){ var readResult= await this.resultProvider.GetValues(identifier, query); if (readResult.Failed) { var error = new ErrorRepresentation(resultReadResult.Message); return this.StatusCode(error.StatusCode); } return this.Ok(readResult.Value);}我應該得到帶有 400 代碼的 http 響應,但我找不到 404。
- 1 回答
- 0 關注
- 71 瀏覽
添加回答
舉報
0/150
提交
取消