本文整理汇总了C#中ConcreteApiController.CreatedAtRoute方法的典型用法代码示例。如果您正苦于以下问题:C# ConcreteApiController.CreatedAtRoute方法的具体用法?C# ConcreteApiController.CreatedAtRoute怎么用?C# ConcreteApiController.CreatedAtRoute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcreteApiController
的用法示例。
在下文中一共展示了ConcreteApiController.CreatedAtRoute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApiController_CreatedAtRoute_Dictionary
public void ApiController_CreatedAtRoute_Dictionary()
{
// Arrange
var controller = new ConcreteApiController();
var product = new Product();
var values = new RouteValueDictionary(new { controller = "Products" });
// Act
var result = controller.CreatedAtRoute("api_route", values, product);
// Assert
var created = Assert.IsType<CreatedAtRouteResult>(result);
Assert.Same(product, created.Value);
Assert.Equal("api_route", created.RouteName);
Assert.Equal("Products", created.RouteValues["controller"]);
Assert.Equal<KeyValuePair<string, object>>(values, created.RouteValues);
}
示例2: ApiController_CreatedAtRoute
public void ApiController_CreatedAtRoute()
{
// Arrange
var controller = new ConcreteApiController();
var product = new Product();
// Act
var result = controller.CreatedAtRoute("api_route", new { controller = "Products" }, product);
// Assert
var created = Assert.IsType<CreatedAtRouteResult>(result);
Assert.Same(product, created.Value);
Assert.Equal("api_route", created.RouteName);
Assert.Equal("Products", created.RouteValues["controller"]);
}