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


C# ViewResult.Should方法代码示例

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


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

示例1: BeRedirect_GivenNotRedirect_ShouldFail

 public void BeRedirect_GivenNotRedirect_ShouldFail()
 {
     ActionResult result = new ViewResult();
     Action a = () => result.Should().BeRedirectResult();
     a.ShouldThrow<Exception>()
             .WithMessage("Expected ActionResult to be \"RedirectResult\", but found \"ViewResult\"");
 }
开发者ID:jrnail23,项目名称:FluentAssertions.MVC,代码行数:7,代码来源:ActionResultAssertions_Tests.cs

示例2: BeEmpty_GivenNotEmpty_ShouldPass

 public void BeEmpty_GivenNotEmpty_ShouldPass()
 {
     ActionResult result = new ViewResult();
     Action a = () => result.Should().BeEmptyResult();
     a.ShouldThrow<Exception>()
             .WithMessage("Expected ActionResult to be \"EmptyResult\", but found \"ViewResult\"");
 }
开发者ID:jrnail23,项目名称:FluentAssertions.MVC,代码行数:7,代码来源:ActionResultAssertions_Tests.cs

示例3: WithMasterName_GivenExpectedValue_ShouldPass

        public void WithMasterName_GivenExpectedValue_ShouldPass()
        {
            ActionResult result = new ViewResult
            {
                MasterName = "master",
            };

            result.Should().BeViewResult().WithMasterName("master");
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:9,代码来源:ViewResultAssertions_Tests.cs

示例4: WithTempData_GivenExpectedValue_ShouldPass

        public void WithTempData_GivenExpectedValue_ShouldPass()
        {
            ActionResult result = new ViewResult
            {
                TempData = new TempDataDictionary { { "key1", "value1" } }
            };

            result.Should().BeViewResult().WithTempData("key1", "value1");
        }
开发者ID:rikrak,项目名称:FluentAssertions.MVC,代码行数:9,代码来源:ViewResultAssertions_Tests.cs

示例5: WithViewName_GivenExpectedValue_ShouldPass

        public void WithViewName_GivenExpectedValue_ShouldPass()
        {
            ActionResult result = new ViewResult
            {
                ViewName = "index",
            };

            result.Should().BeViewResult().WithViewName("index");
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:9,代码来源:ViewResultAssertions_Tests.cs

示例6: WithViewName_GivenUnexpectedValue_ShouldFail

        public void WithViewName_GivenUnexpectedValue_ShouldFail()
        {
            var actualViewName = "index";
            var expectedViewName = "xyz";
            var failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_ViewName, expectedViewName, actualViewName);
            ActionResult result = new ViewResult
            {
                ViewName = actualViewName,
            };

            Action action = () => result.Should().BeViewResult().WithViewName(expectedViewName);
            
            action.ShouldThrow<Exception>()
                    .WithMessage(failureMessage);
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:15,代码来源:ViewResultAssertions_Tests.cs

示例7: WithDefaultViewName_GivenUnexpectedValue_ShouldFail

        public void WithDefaultViewName_GivenUnexpectedValue_ShouldFail()
        {
            string viewName = "index";
            string failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_WithDefaultViewName, viewName);

            ActionResult result = new ViewResult
            {
                ViewName = viewName
            };

            Action action = () => result.Should().BeViewResult().WithDefaultViewName();

            action.ShouldThrow<Exception>()
                    .WithMessage(failureMessage);
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:15,代码来源:ViewResultAssertions_Tests.cs

示例8: WithDefaultViewName_GivenExpectedValue_ShouldPass

        public void WithDefaultViewName_GivenExpectedValue_ShouldPass()
        {
            ActionResult result = new ViewResult
            {
                ViewName = String.Empty
            };

            result.Should().BeViewResult().WithDefaultViewName();
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:9,代码来源:ViewResultAssertions_Tests.cs

示例9: ModelAs_Null_ShouldFail

        public void ModelAs_Null_ShouldFail()
        {
            ActionResult result = new ViewResult();
            string failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_NullModel, typeof(Object).Name);

            Action a = () => result.Should().BeViewResult().ModelAs<Object>();
            
            a.ShouldThrow<Exception>()
                    .WithMessage(failureMessage);
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:10,代码来源:ViewResultAssertions_Tests.cs

示例10: ModelAs_GivenWrongType_ShouldFail

        public void ModelAs_GivenWrongType_ShouldFail()
        {
#if NETCOREAPP1_0
            var result = new TestController().ViewSimpleModel();
#else
            ActionResult result = new ViewResult
            {
                ViewData = new ViewDataDictionary("hello")
            };
#endif

            Action a = () => result.Should().BeViewResult().ModelAs<int>().Should().Be(2);
            a.ShouldThrow<Exception>();
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:14,代码来源:ViewResultAssertions_Tests.cs

示例11: ModelAs_GivenUnexpectedValue_ShouldFail

        public void ModelAs_GivenUnexpectedValue_ShouldFail()
        {
#if NETCOREAPP1_0
            var result = new TestController().ViewSimpleModel();
#else
            ActionResult result = new ViewResult
            {
                ViewData = new ViewDataDictionary("hello")
            };
#endif

            Action a = () => result.Should().BeViewResult().ModelAs<string>().Should().Be("xyx");
            a.ShouldThrow<Exception>();
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:14,代码来源:ViewResultAssertions_Tests.cs

示例12: ModelAs_GivenUnexpectedValue_ShouldFail

        public void ModelAs_GivenUnexpectedValue_ShouldFail()
        {
            ActionResult result = new ViewResult
            {
                ViewData = new ViewDataDictionary("hello")
            };

            Action a = () => result.Should().BeViewResult().ModelAs<string>().Should().Be("xyx");
            a.ShouldThrow<Exception>();
        }
开发者ID:rikrak,项目名称:FluentAssertions.MVC,代码行数:10,代码来源:ViewResultAssertions_Tests.cs

示例13: WithTempData_GivenTwoExpectedValues_ShouldPass

        public void WithTempData_GivenTwoExpectedValues_ShouldPass()
        {
#if NETCOREAPP1_0
            var result = new TestController().ViewWithTwoTempData();
#else
            ActionResult result = new ViewResult
            {
                TempData = new TempDataDictionary
                {
                    { "key1", "value1" },
                    { "key2", "value2" },
                }
            };
#endif

            result.Should().BeViewResult()
                    .WithTempData("key1", "value1")
                    .WithTempData("key2", "value2");
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:19,代码来源:ViewResultAssertions_Tests.cs

示例14: WithViewData_GivenUnexpectedKey_ShouldFail

        public void WithViewData_GivenUnexpectedKey_ShouldFail()
        {
            var actualKey = "key1";
            var expectedKey = "xyz";

#if NETCOREAPP1_0
            var result = new TestController().ViewWithTwoViewData();
#else
            ActionResult result = new ViewResult
            {
                ViewData = new ViewDataDictionary { { actualKey, "value1" } }
            };
#endif
            var failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_ViewData_ContainsKey, expectedKey, actualKey);

            Action a = () => result.Should().BeViewResult().WithViewData(expectedKey, "value1");

            a.ShouldThrow<Exception>()
                    .WithMessage(failureMessage);
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:20,代码来源:ViewResultAssertions_Tests.cs

示例15: WithViewData_GivenUnexpectedValue_ShouldFail

        public void WithViewData_GivenUnexpectedValue_ShouldFail()
        {
            var key = "key1";
            var actualValue = "value1";
            var expectedValue = "abc";
            var failureMessage = FailureMessageHelper.Format(FailureMessages.ViewResultBase_ViewData_HaveValue, key, expectedValue, actualValue);

#if NETCOREAPP1_0
            var result = new TestController().ViewWithOneViewData();
#else
            ActionResult result = new ViewResult
            {
                ViewData = new ViewDataDictionary { { key, actualValue } }
            };
#endif

            Action a = () => result.Should().BeViewResult().WithViewData(key, expectedValue);

            a.ShouldThrow<Exception>()
                    .WithMessage(failureMessage);
        }
开发者ID:kevinkuszyk,项目名称:FluentAssertions.MVC,代码行数:21,代码来源:ViewResultAssertions_Tests.cs


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