﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Vijay Santhanam commented on Don't like visibility levels, change that</title><description>Haack has an interesting post on this topic:
  
http://haacked.com/archive/2007/12/09/writing-unit-tests-for-controller-actions.aspx
  
  
He recommends the Test Specific Subclass if you have protected methods. I think he implies in his post that most protected virtual methods will become public to assist TDD - which would ideally solve this problem.
  
  
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment9</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment9</guid><pubDate>Thu, 27 Dec 2007 12:00:26 GMT</pubDate></item><item><title>Jimmy Bogard commented on Don't like visibility levels, change that</title><description>Just curious, would you recommend this mechanism over something like "Subclass and override"?  For example:
  
  
public class TestController : Controller
  
{
  
    public new virtual void RenderView(string action)
  
    {
  
        base.RenderView(action);
  
    }
  
}
  
  
Slightly more annoying, but with compile-time safety.
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment8</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment8</guid><pubDate>Thu, 13 Dec 2007 14:49:11 GMT</pubDate></item><item><title>Ayende Rahien commented on Don't like visibility levels, change that</title><description>Certainly, 
  
But you won't get the compile time access to that, RhinoMocks works at run time.
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment7</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment7</guid><pubDate>Thu, 13 Dec 2007 14:04:45 GMT</pubDate></item><item><title>H&amp;#229;kan Forss commented on Don't like visibility levels, change that</title><description>I'm a little into John's approach but with a twist.
  
Wouldn't it be possible to have Rhino mock expose all protected methods as public on creation of a partial mock
  
  
  
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment6</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment6</guid><pubDate>Thu, 13 Dec 2007 14:02:36 GMT</pubDate></item><item><title>Ayende Rahien commented on Don't like visibility levels, change that</title><description>John,
  
I am accepting patches :-)
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment5</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment5</guid><pubDate>Thu, 13 Dec 2007 13:31:16 GMT</pubDate></item><item><title>John Chapman commented on Don't like visibility levels, change that</title><description>This may sound like blasphemy, but why doesn't Rhino mocks just add the ability to reference a method by name instead of having to call the method when registering it in the framework in order to handle non-public members.
  
  
I love the way it works for public methods, but if I need to add an extension method and then use reflection to wire up my mock I may as well be using the framework instead since I'll have the weakly typed issues anyway.
  
  
I would just feel dirty using extension methods in this way.  Plus it seems like extra unnecessary steps every time you need to do something like this.
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment4</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment4</guid><pubDate>Thu, 13 Dec 2007 13:23:15 GMT</pubDate></item><item><title>Grimace of Despair commented on Don't like visibility levels, change that</title><description>Could someone hint the guys at Microsoft that their code "protection" through internal/private/protected members all over the place might just not be such a good idea in the light of extensibility?
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment3</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment3</guid><pubDate>Thu, 13 Dec 2007 10:45:07 GMT</pubDate></item><item><title>Thomas Gravgaard commented on Don't like visibility levels, change that</title><description>Just one slight change is needed to the code. The RenderView extension method has to look like this since the original method is protected. But is is still a very neat technique. Seems like MVC is drawing out a lot of the cool stuff you can do with extension methods:
  
  
        public static void RenderView(this Controller self, string action)
  
        {
  
            typeof(Controller).GetMethod("RenderView", 
  
                System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic, 
  
                null, 
  
                new Type[] { typeof(String) },
  
                null
  
                ).Invoke(self, new object[] { action });
  
        }
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment2</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment2</guid><pubDate>Thu, 13 Dec 2007 10:39:38 GMT</pubDate></item><item><title>Haacked commented on Don't like visibility levels, change that</title><description>Nice! I need to update my post with this technique.
</description><link>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment1</link><guid>http://ayende.com/3044/dont-like-visibility-levels-change-that#comment1</guid><pubDate>Thu, 13 Dec 2007 09:29:32 GMT</pubDate></item></channel></rss>