天道酬勤,学无止境

web-api-contrib

使用 WebApiContrib.Testing 测试 ASP.NET Web API POST 和无参数 GET 路由(Testing ASP.NET Web API POST and Parameterless GET Routes with WebApiContrib.Testing)

问题 我正在尝试使用 WebApiContrib.Testing 库设置一些路由测试。 我的测试(像这样)工作正常...... [Test] [Category("Auth Api Tests")] public void TheAuthControllerAcceptsASingleItemGetRouteWithAHashString() { "~/auth/sjkfhiuehfkshjksdfh".ShouldMapTo<AuthController>(c => c.Get("sjkfhiuehfkshjksdfh")); } 我在后期测试中迷失了 - 我目前有以下失败并出现 NotImplementedException ... [Test] [Category("Auth Api Tests")] public void TheAuthControllerAcceptsAPost() { "~/auth".ShouldMapTo<AuthController>(c => c.Post(new AuthenticationCredentialsModel()), "POST"); } 这是完整性的设置和拆卸...... [SetUp] public void SetUpTest() { RouteConfig.RegisterRoutes(RouteTable.Routes

2021-10-25 05:10:27    分类:技术分享    asp.net   asp.net-web-api   tdd   asp.net-web-api-routing   web-api-contrib

Testing ASP.NET Web API POST and Parameterless GET Routes with WebApiContrib.Testing

I am trying to set up some route tests using the WebApiContrib.Testing library. My get tests (like this) work fine... [Test] [Category("Auth Api Tests")] public void TheAuthControllerAcceptsASingleItemGetRouteWithAHashString() { "~/auth/sjkfhiuehfkshjksdfh".ShouldMapTo<AuthController>(c => c.Get("sjkfhiuehfkshjksdfh")); } I am rather lost on the post test - I currently have the following which fails with a NotImplementedException... [Test] [Category("Auth Api Tests")] public void TheAuthControllerAcceptsAPost() { "~/auth".ShouldMapTo<AuthController>(c => c.Post(new

2021-10-24 19:52:47    分类:问答    asp.net   asp.net-web-api   tdd   asp.net-web-api-routing   web-api-contrib