当前位置: 首页>>代码示例>>C#>>正文


C# ConcreteApiController类代码示例

本文整理汇总了C#中ConcreteApiController的典型用法代码示例。如果您正苦于以下问题:C# ConcreteApiController类的具体用法?C# ConcreteApiController怎么用?C# ConcreteApiController使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConcreteApiController类属于命名空间,在下文中一共展示了ConcreteApiController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AccessDependentProperties_UnsetContext

        public void AccessDependentProperties_UnsetContext()
        {
            // Arrange
            var controller = new ConcreteApiController();

            // Act & Assert
            Assert.Null(controller.Context);
            Assert.Null(controller.ModelState);
            Assert.Null(controller.User);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:10,代码来源:ApiControllerTest.cs

示例2: ApiController_BadRequest

        public void ApiController_BadRequest()
        {
            // Arrange
            var controller = new ConcreteApiController();

            // Act
            var result = controller.BadRequest();

            // Assert
            Assert.Equal(StatusCodes.Status400BadRequest, Assert.IsType<BadRequestResult>(result).StatusCode);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:11,代码来源:ApiControllerTest.cs

示例3: ApiController_BadRequest_Message

        public void ApiController_BadRequest_Message()
        {
            // Arrange
            var controller = new ConcreteApiController();

            // Act
            var result = controller.BadRequest("Error");

            // Assert
            var badRequest = Assert.IsType<BadRequestErrorMessageResult>(result);
            Assert.Equal("Error", badRequest.Message);

            var httpError = Assert.IsType<HttpError>(badRequest.Value);
            Assert.Equal("Error", httpError.Message);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:15,代码来源:ApiControllerTest.cs

示例4: AccessDependentProperties

        public void AccessDependentProperties()
        {
            // Arrange
            var controller = new ConcreteApiController();

            var httpContext = new DefaultHttpContext();
            httpContext.User = new ClaimsPrincipal();
            
            var actionContext = new ActionContext(httpContext, new RouteData(), new ControllerActionDescriptor());

            // Act
            controller.ControllerContext = new ControllerContext(actionContext);

            // Assert
            Assert.Same(httpContext, controller.Context);
            Assert.Same(actionContext.ModelState, controller.ModelState);
            Assert.Same(httpContext.User, controller.User);
        }
开发者ID:phinq19,项目名称:git_example,代码行数:18,代码来源:ApiControllerTest.cs

示例5: ApiController_Ok

        public void ApiController_Ok()
        {
            // Arrange
            var controller = new ConcreteApiController();

            // Act
            var result = controller.Ok();

            // Assert
            Assert.Equal(200, Assert.IsType<HttpOkResult>(result).StatusCode);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:11,代码来源:ApiControllerTest.cs

示例6: ApiController_NotFound

        public void ApiController_NotFound()
        {
            // Arrange
            var controller = new ConcreteApiController();

            // Act
            var result = controller.NotFound();

            // Assert
            Assert.Equal(404, Assert.IsType<HttpNotFoundResult>(result).StatusCode);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:11,代码来源:ApiControllerTest.cs

示例7: ApiController_Json_Settings_Encoding

        public void ApiController_Json_Settings_Encoding()
        {
            // Arrange
            var controller = new ConcreteApiController();
            var product = new Product();
            var settings = new JsonSerializerSettings();

            // Act
            var result = controller.Json(product, settings, Encoding.UTF8);

            // Assert
            var jsonResult = Assert.IsType<JsonResult>(result);
            Assert.Same(product, jsonResult.Value);

            var formatter = Assert.IsType<JsonOutputFormatter>(jsonResult.Formatter);
            Assert.Same(settings, formatter.SerializerSettings);
            Assert.Same(Encoding.UTF8, Assert.Single(formatter.SupportedEncodings));
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:18,代码来源:ApiControllerTest.cs

示例8: ApiController_Json

        public void ApiController_Json()
        {
            // Arrange
            var controller = new ConcreteApiController();
            var product = new Product();

            // Act
            var result = controller.Json(product);

            // Assert
            var jsonResult = Assert.IsType<JsonResult>(result);
            Assert.Same(product, jsonResult.Value);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:13,代码来源:ApiControllerTest.cs

示例9: ApiController_ResponseMessage

        public void ApiController_ResponseMessage()
        {
            // Arrange
            var controller = new ConcreteApiController();

            var response = new HttpResponseMessage(HttpStatusCode.NoContent);

            // Act
            var result = controller.ResponseMessage(response);

            // Assert
            var responseResult = Assert.IsType<ResponseMessageResult>(result);
            Assert.Same(response, responseResult.Response);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:14,代码来源:ApiControllerTest.cs

示例10: ApiController_Redirect_String

        public void ApiController_Redirect_String(string uri)
        {
            // Arrange
            var controller = new ConcreteApiController();

            // Act
            var result = controller.Redirect(uri);

            // Assert
            var redirect = Assert.IsType<RedirectResult>(result);
            Assert.Equal(uri, result.Url);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:12,代码来源:ApiControllerTest.cs

示例11: ApiController_Conflict

        public void ApiController_Conflict()
        {
            // Arrange
            var controller = new ConcreteApiController();

            // Act
            var result = controller.Conflict();

            // Assert
            Assert.Equal(StatusCodes.Status409Conflict, Assert.IsType<ConflictResult>(result).StatusCode);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:11,代码来源:ApiControllerTest.cs

示例12: ApiController_Created_String

        public void ApiController_Created_String(string uri)
        {
            // Arrange
            var controller = new ConcreteApiController();

            var product = new Product();

            // Act
            var result = controller.Created(uri, product);

            // Assert
            var created = Assert.IsType<CreatedResult>(result);
            Assert.Same(product, created.Value);
            Assert.Equal(uri, created.Location);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:15,代码来源:ApiControllerTest.cs

示例13: ApiController_Created_Uri

        public void ApiController_Created_Uri()
        {
            // Arrange
            var controller = new ConcreteApiController();

            var uri = new Uri("http://contoso.com/");
            var product = new Product();

            // Act
            var result = controller.Created(uri, product);

            // Assert
            var created = Assert.IsType<CreatedResult>(result);
            Assert.Same(product, created.Value);
            Assert.Equal(uri.OriginalString, created.Location);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:16,代码来源:ApiControllerTest.cs

示例14: ApiController_Ok_Content

        public void ApiController_Ok_Content()
        {
            // Arrange
            var controller = new ConcreteApiController();
            var product = new Product();

            // Act
            var result = controller.Ok(product);

            // Assert
            var okResult = Assert.IsType<OkNegotiatedContentResult<Product>>(result);
            Assert.Same(product, okResult.Content);
        }
开发者ID:RehanSaeed,项目名称:Mvc,代码行数:13,代码来源:ApiControllerTest.cs

示例15: ApiController_Ok_Content

        public void ApiController_Ok_Content()
        {
            // Arrange
            var controller = new ConcreteApiController();
            var product = new Product();

            // Act
            var result = controller.Ok(product);

            // Assert
            var okResult = Assert.IsType<HttpOkObjectResult>(result);
            Assert.Same(product, okResult.Value);
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:13,代码来源:ApiControllerTest.cs


注:本文中的ConcreteApiController类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。