Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
        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));
        }