Пример #1
0
        public void TestIndexConsumerViewingOtherAdvisorProfileEmptyUrl()
        {
            var controller = new AdvisorsController();
            var response   = controller.Index(this.otherConsumerId);

            Assert.IsInstanceOfType(response, typeof(PageForbiddenActionResult));
        }
Пример #2
0
        public void TestIndexToPageNotFound()
        {
            var controller = new AdvisorsController();
            var response   = controller.Index();

            Assert.IsInstanceOfType(response, typeof(PageNotFoundActionResult));
        }
Пример #3
0
        public void TestIndexEmptyViewModel()
        {
            var controller = new AdvisorsController();
            var response   = controller.Index(this.emptyViewModelConsumerId);

            Assert.IsInstanceOfType(response, typeof(PageNotFoundActionResult));
        }
Пример #4
0
        public void TestIndexValidatedSlug()
        {
            var expectedUrl = SeoHelper.ValidateSlug(this.redirectConsumerId, this.expectedUrl);
            var controller  = new AdvisorsController();
            var response    = controller.Index(this.redirectConsumerId);

            Assert.AreEqual(expectedUrl, (response as RedirectResult).Url);
            Assert.IsInstanceOfType(response, typeof(RedirectResult));
        }
Пример #5
0
        public void TestIndexConsumerViewingOtherAdvisorProfile()
        {
            var controller       = new AdvisorsController();
            var expectedRedirect = string.Format("{0}=query=values", AdvisorHelper.GetMyAdvisorUri);

            // set HttpContext to define Request url
            controller.ControllerContext = new ControllerContext()
            {
                Controller  = controller,
                HttpContext = this.GetFakeIndexHttpContext()
            };

            var response = controller.Index(this.otherConsumerId);

            Assert.AreEqual(expectedRedirect, (response as RedirectToRouteResult).RouteValues["action"]);
            Assert.IsInstanceOfType(response, typeof(RedirectToRouteResult));
        }
Пример #6
0
        public void TestIndexHappyPath()
        {
            var expectedViewModel = new AdvisorDetailViewModel()
            {
                attr1 = "value1",
                attr2 = "value2"
            };

            var controller = new AdvisorsController();
            var response   = controller.Index(this.validConsumerId);


            // In order to maintain this simple test,
            // an evaluation of each attribute is carried out,
            // but when it is necessary to evaluate complex objects it is advisable to serialize both objects,
            // the expected value and the current value and the Equal Assertion is made with both serialized values
            Assert.AreEqual(expectedViewModel.attr1, (response as ViewResult).Model.attr1);
            Assert.AreEqual(expectedViewModel.attr2, (response as ViewResult).Model.attr2);
            Assert.IsInstanceOfType(response, typeof(ViewResult));
        }