The Lounge is rated PG. If you're about to post something you wouldn't want your
kid sister to read then don't post it. No flame wars, no abusive conduct, no programming
questions and please don't post ads.
1. The lounge is for the CodeProject community to discuss things of interest to the community, and as a place for the whole community to participate. It is, first and foremost, a respectful meeting and discussion area for those wishing to discuss the life of a Software developer.
The #1 rule is: Be respectful of others, of the site, and of the community as a whole.
2. Technical discussions are welcome, but if you need specific programming question answered please use Quick Answers[^], or to discussion your programming problem in depth use the programming forums[^]. We encourage technical discussion, but this is a general discussion forum, not a programming Q&A forum. Posts will be moved or deleted if they fit better elsewhere.
4. No politics (including enviro-politics[^]), no sex, no religion. This is a community for software development. There are plenty of other sites that are far more appropriate for these discussions.
5. Nothing Not Safe For Work, nothing you would not want your wife/husband, your girlfriend/boyfriend, your mother or your kid sister seeing on your screen. For those discussions where you wish to be a little more frank, use the Soapbox[^]
6. Any personal attacks, any spam, any advertising, any trolling, or any abuse of the rules will result in your account being removed.
7. Not everyone's first language is English. Be understanding.
Please respect the community and respect each other. We are of many cultures so remember that. Don't assume others understand you are joking, don't belittle anyone for taking offense or being thin skinned.
We are a community for software developers. Leave the egos at the door.
instead of "nothing" it should have said "bullshit"
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
The reason that it transcends the stereotypical cartoonic tropes is that it simultaneously embraces the zeitgeist and underlying notions of classical inter-personal theorisation with an added soupcon of whimsy which sugar-coats the fundamental expository of the notion that language can never transcend the merely personal. The bathetic effect of the ultimate frame contraindicates the heroic, yet doomed, optimism of the exposition bring us to a rousing coda unifying the disparate elements of the piece into a crystalline gestalt. The Wittgensteinian undertones provide a scintillating counterpoint to the contemporary setting. 9/10
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
I hate mock. I mean not in general, in general I don't care I just think they are a waste of time.
But I particularly hate them in the case of automated testing.
Not only they make you waste time writing code to set them up in each test, but then you are not testing the real thing, you are testing mocks!
Now the funny thing is, I had some unit test that validated some functionality as working but it was not working for the user and I was completely puzzled...
After writing a little app to test the real thing, turns out I had one insidious mock in my test. Just one. And that was the one thing that worked in the test but failed in the real app!
On top of that it was completely unneeded.. the real interface would have worked just as well (or failed, in that case)
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.
// Contrived example:publicint 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