Esempio n. 1
0
        public void SetDefaultLambda_CanBeChained()
        {
            Route route = new Route("{language}/{year}", new Mock<IRouteHandler>().Object);

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

            Assert.That(route.Defaults["language"], Is.EqualTo("en-US"));
            Assert.That(route.Defaults["year"], Is.EqualTo(2014));
        }
Esempio n. 2
0
        public void SetDefaultLambda_OverwritesExistingDefaultValue()
        {
            Route route = new Route("{language}", new Mock<IRouteHandler>().Object);
            route.Defaults = new RouteValueDictionary { { "language", "hr-HR" } };
            Assert.That(route.Defaults["language"], Is.EqualTo("hr-HR"));

            route.SetDefault(language => "en-US");

            Assert.That(route.Defaults.Count, Is.EqualTo(1));
            Assert.That(route.Defaults.ContainsKey("language"));
            Assert.That(route.Defaults["language"], Is.EqualTo("en-US"));
        }
Esempio n. 3
0
        public void SetDefaultLambda_DefaultsWasNull_SetDefault()
        {
            Route route = new Route("{language}", new Mock<IRouteHandler>().Object);
            route.Defaults = null;
            Assert.That(route.Defaults, Is.Null);

            route.SetDefault(language => "en-US");

            Assert.That(route.Defaults, Is.Not.Null);
            Assert.That(route.Defaults.Count, Is.EqualTo(1));
            Assert.That(route.Defaults.ContainsKey("language"));
            Assert.That(route.Defaults["language"], Is.EqualTo("en-US"));
        }
Esempio n. 4
0
 public void SetDefaultLambda_ReturnsOriginalRoute()
 {
     Route route = new Route("{language}", new Mock<IRouteHandler>().Object);
     Assert.That(route.SetDefault(language => "en-US"), Is.SameAs(route));
 }
Esempio n. 5
0
        public void SetDefault_DefaultsWasNotNull_SetDefault()
        {
            Route route = new Route("{language}", new Mock<IRouteHandler>().Object);
            route.Defaults = new RouteValueDictionary();
            Assert.That(route.Defaults, Is.Not.Null);
            Assert.That(route.Defaults.Count, Is.EqualTo(0));

            route.SetDefault("language", "en-US");

            Assert.That(route.Defaults, Is.Not.Null);
            Assert.That(route.Defaults.Count, Is.EqualTo(1));
            Assert.That(route.Defaults.ContainsKey("language"));
            Assert.That(route.Defaults["language"], Is.EqualTo("en-US"));
        }