Another Quick Tip: Asserting view renders in a MonoRail controller test

posted @ Thursday, September 13, 2007 10:10 AM

 

This is another one of those "blog it so I can remember it" posts.

My last post about a similar tip was relating to asserting redirects in a MonoRail controller.  This one deals with asserting which view is being rendered in your controller when only RenderView is called.

Controller Code
   1: public class CheckoutController : BaseController
   2: {
   3:     public void ValidateOrder(CheckoutOrderDTO orderToValidate)
   4:     {
   5:         // code to validate order
   6:  
   7:         RenderView("review");
   8:     }
   9: }
Controller Test Code
   1: Assert.AreEqual(@"checkout\review", controller.SelectedViewName);

 

It's a subtle difference from asserting redirects, because it doesn't require the leading "/" or the ".rails" extension to be included.

Comments
No comments posted yet.
Post Comment






Please add 7 and 3 and type the answer here: