Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Design for Unit testable
Message
From
01/04/2009 08:53:01
 
 
To
01/04/2009 08:00:25
General information
Forum:
ASP.NET
Category:
Class design
Miscellaneous
Thread ID:
01392535
Message ID:
01392546
Views:
47
>Hi,
>I am using application framework to develop application. The framework come with BusinessObject base class. Developer will always inherit from it to create any other business object.
>
>I have question that, for some method, I am not designed to allow overriable. It has restricted me from unit test, whereby, sometime I need to have "mock" business object so that I don't have to have connection to database. I can just "simulate" the result at the BO.Method(). Since my method is not designed for overriable, it has limited me to do what I need. Most importantly, I need to utilize some of the BO base class function as well.
>
>Now, I am using conditional compilation to achieve this. I would like to know if any better way. I found I can might able to use delegate, but I am not so sure about it. Any advice?

Hi,
Not sure if this helps but if the base method isn't overrideable you could simply hide it in the sub class:
class BaseBO
{
    public void DoSomething(){}
}
class MyBo : BaseBO
{
    public new void DoSomething()
    {
        //Test code.......
        //then call base if ness.
        base.DoSomething();
    }
}
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform