Click here to Skip to main content
15,891,316 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Dilbert OTD Pin
grralph127-Jun-19 1:48
grralph127-Jun-19 1:48 
GeneralMessage Removed Pin
26-Jun-19 20:17
Member 1139640326-Jun-19 20:17 
GeneralMessage Removed Pin
26-Jun-19 20:18
Member 1139640326-Jun-19 20:18 
GeneralMini CCCs 104 Pin
Tim Deveaux26-Jun-19 17:19
Tim Deveaux26-Jun-19 17:19 
GeneralRe: Mini CCCs 104 Pin
Peter_in_278026-Jun-19 18:52
professionalPeter_in_278026-Jun-19 18:52 
GeneralRe: Mini CCCs 104 - Done Pin
Tim Deveaux26-Jun-19 18:58
Tim Deveaux26-Jun-19 18:58 
GeneralFunny test story Pin
Super Lloyd26-Jun-19 15:51
Super Lloyd26-Jun-19 15:51 
GeneralRe: Funny test story Pin
Sander Rossel26-Jun-19 21:29
professionalSander Rossel26-Jun-19 21:29 
Well, they're unit tests, so you're testing units, not multiple units or entire systems (other tests exist for that).
And from the perspective of the unit you're testing it doesn't really matter if IRepository.GetData gets the data from a database, a service or a mock.
From the perspective of the test is does matter since the database and service can't be controlled from the test scenario, but a mock can.
A mock will always return x when the input is y, a database or service might not.
And then the thing you're actually testing can always use value x which should always return value z, which can be asserted.
C#
// Contrived example:
public int AddOneToDbField(IRepository repo)
{
   int dbField = repo.GetNumber(); // This should be mocked.
   return dbField + 1; // This should be tested and asserted.
}
If you want to test your repository you should do stuff like integration testing, although I've also seen unit tests that connect to databases.
But if you're testing your mocks you might not be doing it right Blush | :O

GeneralRe: Funny test story Pin
F-ES Sitecore26-Jun-19 21:47
professionalF-ES Sitecore26-Jun-19 21:47 
GeneralRe: Funny test story Pin
Dr.Walt Fair, PE30-Jun-19 4:39
professionalDr.Walt Fair, PE30-Jun-19 4:39 
GeneralHow many unanswered SO questions? Pin
raddevus26-Jun-19 10:58
mvaraddevus26-Jun-19 10:58 
GeneralRe: How many unanswered SO questions? Pin
Mark_Wallace26-Jun-19 13:23
Mark_Wallace26-Jun-19 13:23 
GeneralRe: How many unanswered SO questions? Pin
raddevus26-Jun-19 13:57
mvaraddevus26-Jun-19 13:57 
GeneralRe: How many unanswered SO questions? Pin
Herman<T>.Instance26-Jun-19 21:56
Herman<T>.Instance26-Jun-19 21:56 
GeneralRe: How many unanswered SO questions? Pin
raddevus27-Jun-19 2:49
mvaraddevus27-Jun-19 2:49 
GeneralRe: How many unanswered SO questions? Pin
PeejayAdams26-Jun-19 23:22
PeejayAdams26-Jun-19 23:22 
GeneralRe: How many unanswered SO questions? Pin
raddevus27-Jun-19 2:50
mvaraddevus27-Jun-19 2:50 
GeneralRe: How many unanswered SO questions? Pin
PeejayAdams27-Jun-19 3:05
PeejayAdams27-Jun-19 3:05 
GeneralRe: How many unanswered SO questions? Pin
Richard Deeming27-Jun-19 2:29
mveRichard Deeming27-Jun-19 2:29 
GeneralRe: How many unanswered SO questions? Pin
StarNamer@work28-Jun-19 1:52
professionalStarNamer@work28-Jun-19 1:52 
GeneralRe: How many unanswered SO questions? Pin
kalberts27-Jun-19 10:39
kalberts27-Jun-19 10:39 
GeneralRe: How many unanswered SO questions? Pin
raddevus28-Jun-19 2:48
mvaraddevus28-Jun-19 2:48 
GeneralYou know it's time for a break from the compiler when... Pin
Chris Maunder26-Jun-19 8:54
cofounderChris Maunder26-Jun-19 8:54 
QuestionRe: You know it's time for a break from the compiler when... Pin
Eddy Vluggen26-Jun-19 8:57
professionalEddy Vluggen26-Jun-19 8:57 
AnswerRe: You know it's time for a break from the compiler when... Pin
Dave Kreskowiak26-Jun-19 9:01
mveDave Kreskowiak26-Jun-19 9:01 

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.