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


C# Framework.HttpGet方法代码示例

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


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

示例1: It_should_throw_InvalidCastException

        public void It_should_throw_InvalidCastException()
        {
            var mvc = new Framework();

            // c.Index() returns a ViewResult.  but, we're typecasting to ContentResult here.  so, should throw InvalidCastException.
            Assert.Throws<InvalidCastException>(() => mvc.HttpGet<SampleController, ContentResult>(c => c.Index()));
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:7,代码来源:When_wrong_ActionResult_specified.cs

示例2: It_should_display_a_CreateModelView

        public void It_should_display_a_CreateModelView()
        {
            var mvc = new Framework();

            var result = mvc.HttpGet<CategoryController, ViewResult>(c => c.Create());

            Assert.IsInstanceOf<CreateModelView>(result.ActionResult.Model);
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:8,代码来源:When_page_is_first_loaded.cs

示例3: 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.AddQueryStringFixture("firstName", "peter");

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

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

示例4: It_should_display_a_list_of_categories

        public void It_should_display_a_list_of_categories()
        {
            // ARRANGE
            var mvc = new Framework();
            var repoStub = mvc.Inject<Mock<ICategoryRepository>>();
            var categoriesActual = new List<Category> {mvc.New<Category>()};

            repoStub.Setup(r => r.FindAll()).Returns(categoriesActual.AsQueryable());

            // ACT
            var result = mvc.HttpGet<HomeController, ViewResult>(c => c.Index());
            var categoriesExpected = result.ActionResult.Model as List<Category>;

            // ASSERT
            Assert.That(categoriesExpected.Count, Is.EqualTo(1));
            Assert.That(categoriesExpected[0].Id, Is.EqualTo(categoriesActual[0].Id));
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:17,代码来源:When_page_is_first_loaded.cs

示例5: It_should_display_no_categories_found_message

        public void It_should_display_no_categories_found_message()
        {
            // ARRANGE
            var mvc = new Framework();
            var repoStub = mvc.Inject<Mock<ICategoryRepository>>();
            IQueryable<Category> categories = null;     // no items

            repoStub.Setup(r => r.FindAll()).Returns(categories);

            // ACT
            var result = mvc.HttpGet<CategoryController, ViewResult>(c => c.Index());

            // ASSERT
            var viewModel = result.ActionResult.Model as IndexViewModel;

            Assert.That(viewModel.GetNoCategoriesMessage(), Is.EqualTo("No categories found."));
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:17,代码来源:When_there_are_no_categories.cs

示例6: It_should_display_a_list_of_categories

        public void It_should_display_a_list_of_categories()
        {
            // ARRANGE
            var mvc = new Framework();
            var repoStub = mvc.Inject<Mock<ICategoryRepository>>();
            var categoriesExpected = new List<Category>
                             {
                                 new Category { Id = 123, Name = "category1" },
                                 new Category { Id = 234, Name = "category2"}
                             };

            repoStub.Setup(r => r.FindAll()).Returns(categoriesExpected.AsQueryable());

            // ACT
            var result = mvc.HttpGet<CategoryController, ViewResult>(c => c.Index());

            // ASSERT
            var viewModel = result.ActionResult.Model as IndexViewModel;
            var categoriesActual = viewModel.Categories.ToArray();

            Assert.That(categoriesActual.Length, Is.EqualTo(2));
            Assert.That(categoriesActual[0].Id, Is.EqualTo(123));
            Assert.That(categoriesActual[1].Id, Is.EqualTo(234));
        }
开发者ID:ptran123,项目名称:Conceptual,代码行数:24,代码来源:When_page_is_first_loaded.cs


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