Click here to Skip to main content
15,892,059 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.

 
AnswerRe: Sharepoint? Pin
Gerry Schmitz24-Oct-16 7:23
mveGerry Schmitz24-Oct-16 7:23 
AnswerRe: Sharepoint? Pin
Дмитрий Блинков25-Oct-16 20:57
Дмитрий Блинков25-Oct-16 20:57 
QuestionUnit Testing/TDD Help Pin
TheOnlyRealTodd21-Oct-16 12:42
professionalTheOnlyRealTodd21-Oct-16 12:42 
AnswerRe: Unit Testing/TDD Help Pin
Eddy Vluggen21-Oct-16 13:02
professionalEddy Vluggen21-Oct-16 13:02 
AnswerRe: Unit Testing/TDD Help Pin
Marc Clifton21-Oct-16 14:31
mvaMarc Clifton21-Oct-16 14:31 
GeneralRe: Unit Testing/TDD Help Pin
Mark_Wallace21-Oct-16 21:02
Mark_Wallace21-Oct-16 21:02 
GeneralRe: Unit Testing/TDD Help Pin
Marc Clifton22-Oct-16 3:49
mvaMarc Clifton22-Oct-16 3:49 
AnswerRe: Unit Testing/TDD Help Pin
Sander Rossel22-Oct-16 2:01
professionalSander Rossel22-Oct-16 2:01 
Your first test seems weird and unnecessary...
If you decide to overwrite the ToString method (maybe for debugging purposes) your test will fail, while it wouldn't actually fail any business requirement (unless you actually use ToString in your business, but I can advice against that).
Besides, you're using a strong typed language so if you change the type your code wouldn't even compile (let alone run that test)!
If you really want to check the type check it using typeof so that your test doesn't break if you even only rename your class.
In fact, you're testing if a constructor actually constructs, if it wouldn't you'd have bigger problems than that one unit test (because C# just broke)! Dead | X|
Test only what is important for your business cases. The statistics on the array are important, because you can't have a customer get a wrong average or count of his invoices (or whatever it is you're doing). Testing whether a class has a certain name is not important (save, maybe, for some edge-cases with reflection).
TheOnlyRealTodd wrote:
But then I was questioning whether I should even be testing these methods since they are using built-in provided standard library algorithms rather than my own custom algorithms in the first place.
Yes, you should test them.
Test your public methods like you don't know the implementation. In fact, you're testing now to prevent your code from accidentally breaking in the future. Testing it lets you change your implementation in the future without worrying you'll break anything.
Be sure to test with null and empty arrays and rounding errors in your average (especially since it's a floating point type) Smile | :)

I also agree with Marc by the way. Your tests are there for your code and not the other way around. TDD does switch it around though.
I've worked on a project where every method was public so it was testable... Not quite how it should work. It only prevented us from changing implementation details because tests, that didn't affect business requirements, would break.
Good luck with your testing adventures. I still find testing a very difficult subject!
Read my (free) ebook Object-Oriented Programming in C# Succinctly.
Visit my blog at Sander's bits - Writing the code you need.
Or read my articles here on CodeProject.
Simplicity is prerequisite for reliability.
— Edsger W. Dijkstra
Regards,
Sander

AnswerRe: Unit Testing/TDD Help Pin
AndrewDavie24-Oct-16 5:01
AndrewDavie24-Oct-16 5:01 
GeneralWas Checking Out Github: Then It Was gone - DDoS Pin
raddevus21-Oct-16 9:59
mvaraddevus21-Oct-16 9:59 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Vincent Maverick Durano21-Oct-16 10:05
professionalVincent Maverick Durano21-Oct-16 10:05 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Mark_Wallace21-Oct-16 10:16
Mark_Wallace21-Oct-16 10:16 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Afzaal Ahmad Zeeshan21-Oct-16 10:21
professionalAfzaal Ahmad Zeeshan21-Oct-16 10:21 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Mark_Wallace21-Oct-16 11:13
Mark_Wallace21-Oct-16 11:13 
JokeRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Afzaal Ahmad Zeeshan21-Oct-16 11:14
professionalAfzaal Ahmad Zeeshan21-Oct-16 11:14 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Mark_Wallace21-Oct-16 11:28
Mark_Wallace21-Oct-16 11:28 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
raddevus21-Oct-16 10:33
mvaraddevus21-Oct-16 10:33 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Vincent Maverick Durano21-Oct-16 10:35
professionalVincent Maverick Durano21-Oct-16 10:35 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Afzaal Ahmad Zeeshan21-Oct-16 10:20
professionalAfzaal Ahmad Zeeshan21-Oct-16 10:20 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Ryan Peden21-Oct-16 10:27
professionalRyan Peden21-Oct-16 10:27 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
raddevus21-Oct-16 10:32
mvaraddevus21-Oct-16 10:32 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Nish Nishant21-Oct-16 11:27
sitebuilderNish Nishant21-Oct-16 11:27 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
DaveAuld21-Oct-16 18:29
professionalDaveAuld21-Oct-16 18:29 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
2374121-Oct-16 10:56
2374121-Oct-16 10:56 
GeneralRe: Was Checking Out Github: Then It Was gone - DDoS Pin
Chris Maunder21-Oct-16 11:15
cofounderChris Maunder21-Oct-16 11:15 

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.