Defining RedirectToHomePage in a RouterController

 Given a RouterController
 When RedirectToHomePage 
 Should Redirect the Response to HomePageUrl

Test Code using Static Constructs

    [TestClass]
    public class Given_RouterController {

        readonly RouterController Subject = Create.TestObjectFor<RouterController>();

        readonly Response Response = TestObjectFor<Response>();

        [TestMethod]
        public void When_RedirectToHomePage_Should_Redirect_the_Response_to_HomePageUrl() {

            Subject.Response = Response;
            Subject.RedirectToHomePage();
            Then.Should(Subject).Response.Redirect(Settings.HomePageUrl);
        }
    }

Test Code using Static Constructs

    [TestClass]
    public class Given_RouterController {

        readonly RouterController Subject = Create.TestObjectFor<RouterController>();

        readonly Response Response = TestObjectFor<Response>();

        [TestMethod]
        public void When_RedirectToHomePage_Should_Redirect_the_Response_to_HomePageUrl() {

            Subject.Response = Response;
            Subject.RedirectToHomePage();
            Subject.Should().Response.Redirect(Settings.HomePageUrl);
        }
    }

Production Code

    public class RouterController {

        public Response Response { set; private get; }

        public void RedirectToHomePage() {
            Response.Redirect(Settings.HomePageUrl);
        }
    }

    public interface Response {

        void Redirect(string url);
    }

Last edited Nov 5, 2008 at 7:39 PM by mikemps, version 3

Comments

No comments yet.