Defining Process in a RouterController

 Given a RouterController
 When Process
 Should Transfer BlogEntries to BlogEntryPage 
 Should Redirect to HomePage by default

Test Code

    [TestClass]
    public class Given_RouterController_When_Process : BehaviorOf<RouterController> {

        [TestMethod]
        public void Should_Transfer_BlogEntries_to_BlogEntryPage() {
            
            Given.IsBlogEntry.WillReturn(true);
            When.Process();
            Should.TransferToBlogEntryPage();
        }
        
        [TestMethod]
        public void Should_Redirect_to_HomePage_by_default() {

            When.Process();
            Should.RedirectToHomePage();
        }
    }

Production Code

    public class RouterController {

        public void Process(string request) { 
            if (IsBlogEntry) TransferToBlogEntryPage();
            else RedirectToHomePage();
        }

        public virtual bool IsBlogEntry { 
            get { throw new NotImplementedException(); }
        }

        public virtual void TransferToBlogEntryPage() {}

        public virtual void RedirectToHomePage() {}

    }

Last edited Nov 5, 2008 at 4:41 AM by mikemps, version 2

Comments

No comments yet.