Compare commits

..

19 Commits

@ -113,5 +113,22 @@ namespace xUnitStudy.WebApi.Test
Assert.True(true,"使用Theory特性和InlineData特性传递不同参数多次执行测试");
}
/// <summary>
/// 断言不抛出异常
/// </summary>
[Fact]
public void Assert_NoThrow_Test()
{
Action noThrowAction =() =>
{
//业务代码
Task.Delay(10);
//throw new Exception("测试异常");
};
var exception = Record.Exception(noThrowAction);
Assert.Null(exception);
}
}
}

@ -18,15 +18,23 @@ namespace xUnitStudy.WebApi.Controllers
return new string[] { "value1", "value2" };
}
// GET api/values/5
[System.Web.Http.Authorize]
public string Get(int id)
{
return id.ToString();
}
// POST api/values
public void Post([FromBody]string value)
public IHttpActionResult Post([FromBody]string value)
{
var cc = new System.Web.Http.Results.CreatedAtRouteNegotiatedContentResult<string>
(
"",
new Dictionary<string, object> { { "id",2} },
"",
this
);
return cc;
}
// PUT api/values/5

Loading…
Cancel
Save