本文整理匯總了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));
}
示例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));
}
示例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));
}
示例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));
}