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.
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
"Unanswered" is a bit of a misnomer as some have been "de-answered".
Take a look at the top one on the list, for example - it's protected due to answers having to be removed. Whether that's an OP not accepting one or an overzealous mod or a genuine case of all the answers being totally unhelpful, we will never know.
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
A few times, I tried to get help from the SO community. Every single time, I was met with insults, of the kind "Something similar to this was answered way back in 2003 - what kind of idiot are you that cannot dig up that answer and stop bothering us?"
I guess that a sizable fraction of those five million help seekers have come to the same conclusion than I have: Trying to push something on SO is futile. You can search it to see if anyone has run into exactly the same problem as you have, and received decent help. If not, search somewhere else for an answer.
I'd be curious to know how many unique users are behind those five million questions. But the really interesting question is how many have recieved more or less insulting answers, like me, and then decided that SO is not a place to get help. Software masochists may get some satisfaction there, but I happen not to be in that group.
Yeah, I agree. SO can be a very bad experience. And, if you can believe it, I've had an even worse time at electronics.stackexchange.com (stackexchange is the parent to SO and the site is related).
At one point I asked a question about voltage ratings on capacitors that I really wanted to know the answer about and they literally deleted my question and it took me a long time to write it up so that it was detailed and meaningful.