Click here to Skip to main content
15,899,126 members
Home / Discussions / C#
   

C#

 
AnswerRe: Exception When Streaming Content Over localhost Pin
leppie8-Jul-08 21:05
leppie8-Jul-08 21:05 
GeneralRe: Exception When Streaming Content Over localhost Pin
#realJSOP8-Jul-08 23:35
professional#realJSOP8-Jul-08 23:35 
GeneralRe: Exception When Streaming Content Over localhost Pin
leppie9-Jul-08 1:35
leppie9-Jul-08 1:35 
GeneralRe: Exception When Streaming Content Over localhost Pin
#realJSOP9-Jul-08 9:19
professional#realJSOP9-Jul-08 9:19 
QuestionDownload mail Pin
hadad8-Jul-08 5:51
hadad8-Jul-08 5:51 
AnswerRe: Download mail Pin
User 66588-Jul-08 6:04
User 66588-Jul-08 6:04 
QuestionDTSx [modified] Pin
Paresh Gujarathi8-Jul-08 5:42
Paresh Gujarathi8-Jul-08 5:42 
QuestionWhen to test concrete classes in TDD? Pin
Pawel Krakowiak8-Jul-08 5:19
Pawel Krakowiak8-Jul-08 5:19 
I am just starting my adventure with test driven development (thanks to ASP.NET MVC!) and have a concern, I need to clarify something.

I have an interface like this...

public interface IUserRepository
{
    IUser FetchByID(int userID);
}


and a class which implements that interface:

public class UserRepository : IUserRepository
{
    public IUser FetchByID(int userID)
    {
        User user = null;

        // Do various checks.
        // Fetch data from DB and assign to the user variable.

        return user;
    }
}


I want to test the FetchByID() method. I can mock IUserRepository and return a dummy User object, which is fine and works well. But this means the concrete class (UserRepository) is never tested, so even if I didn't implement that class whatsoever, or I had throw new NotImplementedException() in that method the unit test would still pass since it's using a mock object. I thought you don't want to hit the database (or other external resources) while running your tests and that's the main reason to use mock objects, but that way you never can tell if you implemented that class correctly (or at all!). My colleague told me that when I'm testing that method I should use the concrete class and actually hit the database, and that I should mock IUserRepository only when it's needed in other tests (which are not testing FetchByID() but need data from it). Is that the correct approach?

If so, then my tests will get slower and rely on whether the test DB was properly setup, etc. Perhaps such tests should be placed in a separate project (integration tests)?
AnswerRe: When to test concrete classes in TDD? Pin
N a v a n e e t h8-Jul-08 16:39
N a v a n e e t h8-Jul-08 16:39 
AnswerRe: When to test concrete classes in TDD? Pin
N a v a n e e t h8-Jul-08 16:51
N a v a n e e t h8-Jul-08 16:51 
GeneralRe: When to test concrete classes in TDD? Pin
Pawel Krakowiak8-Jul-08 22:47
Pawel Krakowiak8-Jul-08 22:47 
Questionwebpage calling windows service Pin
adam_smith_20038-Jul-08 5:08
adam_smith_20038-Jul-08 5:08 
AnswerRe: webpage calling windows service Pin
Christian Graus8-Jul-08 5:19
protectorChristian Graus8-Jul-08 5:19 
GeneralRe: webpage calling windows service Pin
adam_smith_20038-Jul-08 5:25
adam_smith_20038-Jul-08 5:25 
GeneralRe: webpage calling windows service Pin
Christian Graus8-Jul-08 5:37
protectorChristian Graus8-Jul-08 5:37 
AnswerRe: webpage calling windows service Pin
PIEBALDconsult8-Jul-08 7:29
mvePIEBALDconsult8-Jul-08 7:29 
QuestionIdentifying CD "format" Pin
arronhuk8-Jul-08 4:49
arronhuk8-Jul-08 4:49 
Questionvarchar(50) or nvarchar(50)? Pin
mrcooll8-Jul-08 4:40
mrcooll8-Jul-08 4:40 
AnswerRe: varchar(50) or nvarchar(50)? PinPopular
Guffa8-Jul-08 4:50
Guffa8-Jul-08 4:50 
GeneralRe: varchar(50) or nvarchar(50)? Pin
Christian Graus8-Jul-08 5:18
protectorChristian Graus8-Jul-08 5:18 
JokeRe: varchar(50) or nvarchar(50)? Pin
Luc Pattyn8-Jul-08 6:10
sitebuilderLuc Pattyn8-Jul-08 6:10 
QuestionCustomizing a .NET setup dynamically Pin
orangeflow8-Jul-08 3:50
orangeflow8-Jul-08 3:50 
AnswerRe: Customizing a .NET setup dynamically Pin
Rutvik Dave8-Jul-08 8:28
professionalRutvik Dave8-Jul-08 8:28 
QuestionProblem in FontStyle property Pin
Krishnraj8-Jul-08 3:38
Krishnraj8-Jul-08 3:38 
AnswerRe: Problem in FontStyle property Pin
Luc Pattyn8-Jul-08 3:46
sitebuilderLuc Pattyn8-Jul-08 3:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.