Let's say that I have the following (useless) method...
public void GetMessage() {
Message m = _messageQueue.Receive();
}
Now I'm tied to MSMQ (which is not the problem), but it makes it hard to test because
I've got to preload a queue with messages before I can test.
What if I did this...
public void GetMessage() {
IMsgQ msgQ = GetFromConfig("messagequeue");
Message m = msgQ.Receive();
}
Pretty much the same method, just I replaced the object MessageQueue with an interface
IMsgQ. And I look up the implementation of that interface from a configuration file.
Now when I test, I can simply plug a dummy implementation in.
I was wondering, how many people do this? What are some other ways that you are
accomplishing the same thing?
Thanks!
Justin Rudd
http://www.pinetree-tech.com/
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.