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>();

        [TestMethod]
        public void When_RedirectToHomePage_Should_Redirect_the_Response_to_HomePageUrl() {

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

Test Code using Extensions Constructs

    [TestClass]
    public class Given_RouterController {

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

        [TestMethod]
        public void When_RedirectToHomePage_Should_Redirect_the_Response_to_HomePageUrl() {

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

Production Code

    public class RouterController {

        public Response Response { get; set; }

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

    public interface Response {

        void Redirect(string url);
    }

Last edited Nov 5, 2008 at 7:27 PM by mikemps, version 1

Comments

No comments yet.