Exemplo n.º 1
0
        public void SiteSelectorController_CallTheIndexAction_EnsuresDefaultSiteHasProperUrlFromQueryString()
        {
            var sites = new List <SiteViewModel>
            {
                new SiteViewModel {
                    IsCurrent = true
                }
            };

            // Arrange
            using (var controller = new TeststableSiteSelectorController(new EmptySiteSelectorMode(sites)))
            {
                var queryString = new NameValueCollection();
                queryString.Add("name", "value");

                var dummyHttpContext = new MyDummyHttpContext(queryString);
                controller.ControllerContext = new ControllerContext(dummyHttpContext, new RouteData {
                }, controller);

                // Act
                var view = controller.Index() as ViewResult;

                var firstSite = sites.First();

                // Assert
                Assert.IsNotNull(firstSite);
                Assert.IsNotNull(view);
                Assert.IsTrue(firstSite.Url == "?name=value");
            }
        }
        public void SiteSelectorController_CallTheIndexAction_EnsuresDefaultSiteHasProperUrlFromQueryString()
        {
            var sites = new List<SiteViewModel>
            {
                new SiteViewModel { IsCurrent = true }
            };

            // Arrange
            using (var controller = new TeststableSiteSelectorController(new EmptySiteSelectorMode(sites)))
            {
                var queryString = new NameValueCollection();
                queryString.Add("name", "value");

                var dummyHttpContext = new MyDummyHttpContext(queryString);
                controller.ControllerContext = new ControllerContext(dummyHttpContext, new RouteData { }, controller);

                // Act
                var view = controller.Index() as ViewResult;

                var firstSite = sites.First();

                // Assert
                Assert.IsNotNull(firstSite);
                Assert.IsNotNull(view);
                Assert.IsTrue(firstSite.Url == "?name=value");
            }
        }
Exemplo n.º 3
0
        public void SiteSelectorController_CallTheIndexAction_EnsuresDefaultModelPropertiesArePresented()
        {
            // Arrange
            using (var controller = new TeststableSiteSelectorController())
            {
                // Act
                var view = controller.Index() as ViewResult;

                // Assert
                Assert.IsNotNull(view);
                Assert.IsTrue(view.ViewName == "SiteSelector.SiteLinks");
            }
        }
        public void SiteSelectorController_CallTheIndexAction_EnsuresDefaultModelPropertiesArePresented()
        {
            // Arrange
            using (var controller = new TeststableSiteSelectorController())
            {
                // Act
                var view = controller.Index() as ViewResult;

                // Assert
                Assert.IsNotNull(view);
                Assert.IsTrue(view.ViewName == "SiteSelector.SiteLinks");
            }
        }
Exemplo n.º 5
0
        public void SiteSelectorController_CallTheIndexAction_EnsuresChangingViewName()
        {
            // Arrange
            using (var controller = new TeststableSiteSelectorController())
            {
                string templateName = "CustomTemplateName";

                controller.TemplateName = templateName;

                // Act
                var view = controller.Index() as ViewResult;

                // Assert
                Assert.IsNotNull(view);
                Assert.IsTrue(view.ViewName == ("SiteSelector." + templateName));
            }
        }
        public void SiteSelectorController_CallTheIndexAction_EnsuresChangingViewName()
        {
            // Arrange
            using (var controller = new TeststableSiteSelectorController())
            {
                string templateName = "CustomTemplateName";

                controller.TemplateName = templateName;

                // Act
                var view = controller.Index() as ViewResult;

                // Assert
                Assert.IsNotNull(view);
                Assert.IsTrue(view.ViewName == ("SiteSelector." + templateName));
            }
        }