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


C# Framework.Inject方法代码示例

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


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

示例1: 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

示例2: 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

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