I did not find a test for JsonReturnBinderAttribute, however I tried this:

namespace ProjectBase.Utils.Test
{
        [TestFixture]
        public class XmlReturnBinderTests : BaseControllerTest
        {
                [Test]
                public void XmlReturnBinderAttributeShouldReturnValidXml()
                {
                        var controller = new TestController();
                        PrepareController(controller);
                        
                        controller.Method();

                        Assert.AreEqual("text/xml", Response.ContentType);
                }
        }

        public class TestController:Controller
        {
                [return:XmlReturnBinder]
                public List<string> Method()
                {
                        return new List<string> { "a", "b", "c" };
                }
        }
}

and assuming my return binder does nothing else than
context.Response.ContentType = "text/xml";

the test still fails (value is still "text/html"). Debugging reveals
the attribute is not called.

When I try to attack from there:
                public void XmlReturnBinderAttributeShouldReturnValidXml()
                {
                        
                        var attr = new XmlReturnBinderAttribute();
                        var context = new Mock<IEngineContext>().Object;
                        var controller = new Mock<IController>().Object;
                        var controllerContext = new 
Mock<IControllerContext>().Object;
                        var returnType = typeof(IList<string>);
                        var returnValue = new List<string> {"a", "b", "c"};

                        attr.Bind(context, controller, controllerContext, 
returnType, returnValue);


                }

how could I get to the underlying stream? seems complicated, I would
have to mock out response and the stream it writes to. I don't
actually know, how to get to this...


How could I test that?


-- 
Jan
___________________
[EMAIL PROTECTED]
www.limpens.com
+55 (11) 3082-1087
+55 (11) 3097-8339

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to