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


C# Framework.HttpPost方法代码示例

本文整理汇总了C#中Framework.HttpPost方法的典型用法代码示例。如果您正苦于以下问题:C# Framework.HttpPost方法的具体用法?C# Framework.HttpPost怎么用?C# Framework.HttpPost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Framework的用法示例。


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

示例1: It_should_be_able_to_read_the_value_out

        public void It_should_be_able_to_read_the_value_out()
        {
            //  ARRANGE
            var mvc = new Framework();

            mvc.HttpContext.AddCookieFixture("firstName", "peter");

            //  ACT
            var result = mvc.HttpPost<SampleController, ContentResult>(c => c.Index(), null);

            //  ASSERT
            Assert.That(result.ActionResult.Content, Is.EqualTo("peter"));
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:13,代码来源:When_there_is_a_value_in_the_cookie_collection.cs

示例2: It_should_add_error_to_ModelState

        public void It_should_add_error_to_ModelState()
        {
            //  ARRANGE
            var mvc = new Framework();
            var model = mvc.New<SampleModel>();

            model.Name = "ptran";   // greater than 5 characters.  should pass validation

            // ACT
            var result = mvc.HttpPost<SampleController, ViewResult>(c => c.Index(model), model);

            //  ASSERT
            Assert.True(result.ModelStateValidationResult.IsValid);
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:14,代码来源:When_model_implements_IValidatableObject_and_validation_passes.cs

示例3: It_should_add_error_to_ModelState

        public void It_should_add_error_to_ModelState()
        {
            //  ARRANGE
            var mvc = new Framework();
            var model = mvc.New<SampleModel>();

            model.Name = "p";   // less then 5 characters.  should fail validation

            // ACT
            var result = mvc.HttpPost<SampleController, ViewResult>(c => c.Index(model), model);

            //  ASSERT
            var hasError = result.ModelStateValidationResult.HasError<SampleModel>(m => m.Name, "Invalid length.");
            Assert.True(hasError);
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:15,代码来源:When_model_implements_IValidatableObject_and_validation_fails.cs

示例4: It_should_add_error_to_modelstate

        public void It_should_add_error_to_modelstate()
        {
            //  ARRANGE
            var mvc = new Framework();
            var model = mvc.New<SampleModel>();

            model.Name = null;

            //  ACT
            var result = mvc.HttpPost<SampleController, ViewResult>(c => c.Index(model), model);

            //  ASSERT
            var hasError = result.ModelStateValidationResult.HasError<SampleModel>(m => m.Name, "Name is required.");
            Assert.True(hasError);
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:15,代码来源:When_model_property_has_RequiredAttribute_and_validation_fails.cs

示例5: It_should_display_an_error_message

        public void It_should_display_an_error_message()
        {
            // ARRANGE
            var mvc = new Framework();
            var modelView = new CreateModelView();

            modelView.CategoryName = null;

            // ACT
            var result = mvc.HttpPost<CategoryController, ViewResult>(c => c.Create(modelView), modelView);
            var model = result.ActionResult.Model as CreateModelView;

            // ASSERT
            Assert.That(result.ModelStateValidationResult.HasError<CreateModelView>(mv => mv.CategoryName, "A category is required."));
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:15,代码来源:When_category_is_empty_on_save.cs


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