當前位置: 首頁>>代碼示例>>C#>>正文


C# Route.SetDefaults方法代碼示例

本文整理匯總了C#中System.Web.Routing.Route.SetDefaults方法的典型用法代碼示例。如果您正苦於以下問題:C# Route.SetDefaults方法的具體用法?C# Route.SetDefaults怎麽用?C# Route.SetDefaults使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Web.Routing.Route的用法示例。


在下文中一共展示了Route.SetDefaults方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SetDefaults_ReturnsOriginalRoute

 public void SetDefaults_ReturnsOriginalRoute()
 {
     Route route = new Route("{language}/{year}", new Mock<IRouteHandler>().Object);
     Assert.That(route.SetDefaults(language => "en-US", year => 2014), Is.SameAs(route));
 }
開發者ID:hudo,項目名稱:SwissKnife,代碼行數:5,代碼來源:RouteExtensionsTests.cs

示例2: SetDefaults_DefaultsWasNull_SetDefaults

        public void SetDefaults_DefaultsWasNull_SetDefaults()
        {
            Route route = new Route("{language}/{year}", new Mock<IRouteHandler>().Object);
            route.Defaults = null;
            Assert.That(route.Defaults, Is.Null);

            route.SetDefaults(language => "en-US", year => 2014);

            Assert.That(route.Defaults, Is.Not.Null);
            Assert.That(route.Defaults.Count, Is.EqualTo(2));
            Assert.That(route.Defaults.ContainsKey("language"));
            Assert.That(route.Defaults.ContainsKey("year"));
            Assert.That(route.Defaults["language"], Is.EqualTo("en-US"));
            Assert.That(route.Defaults["year"], Is.EqualTo(2014));
        }
開發者ID:hudo,項目名稱:SwissKnife,代碼行數:15,代碼來源:RouteExtensionsTests.cs

示例3: SetDefaults_OverwritesExistingDefaultValue

        public void SetDefaults_OverwritesExistingDefaultValue()
        {
            Route route = new Route("{language}/{year}", new Mock<IRouteHandler>().Object);
            route.Defaults = new RouteValueDictionary { { "language", "hr-HR" }, { "year", 2000} };
            Assert.That(route.Defaults["language"], Is.EqualTo("hr-HR"));
            Assert.That(route.Defaults["year"], Is.EqualTo(2000));

            route.SetDefaults(language => "en-US", year => 2014);

            Assert.That(route.Defaults.Count, Is.EqualTo(2));
            Assert.That(route.Defaults.ContainsKey("language"));
            Assert.That(route.Defaults.ContainsKey("year"));
            Assert.That(route.Defaults["language"], Is.EqualTo("en-US"));
            Assert.That(route.Defaults["year"], Is.EqualTo(2014));
        }
開發者ID:hudo,項目名稱:SwissKnife,代碼行數:15,代碼來源:RouteExtensionsTests.cs

示例4: SetDefaults_CanBeChained

        public void SetDefaults_CanBeChained()
        {
            Route route = new Route("{language}/{year}", new Mock<IRouteHandler>().Object);

            route.SetDefaults(language => "en-US").SetDefaults(year => 2014);

            Assert.That(route.Defaults["language"], Is.EqualTo("en-US"));
            Assert.That(route.Defaults["year"], Is.EqualTo(2014));
        }
開發者ID:hudo,項目名稱:SwissKnife,代碼行數:9,代碼來源:RouteExtensionsTests.cs


注:本文中的System.Web.Routing.Route.SetDefaults方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。