hmol / LinkCrawler

Find broken links in webpage
MIT License
117 stars 59 forks source link

Added a MockSettings class for dependency injection unit testing purp… #17

Closed paulhtrott closed 8 years ago

paulhtrott commented 8 years ago

@hmol

Please review my pull request. I didn't do many changes, wanted to be sure I was doing things up to your expectations before continuing forward. You don't have to merge it in, just let me know if it is ok if I am creating Mock Classes, etc., and my style is ok.

hmol commented 8 years ago

Hello @paulhtrott , sorry for taking so long. I have been away on vacation. Your code looks simple and should work, but I would want the MockSettings.cs inside the test project.

Side note: Sorry for not specifically saying this in the issue, but I would like to have more tests that test the functionality of the methods inside LinkCrawler.cs.

paulhtrott commented 8 years ago

Hi @hmol ... thanks for the input!

I can test the LinkCrawler class, BUT as it is written it will be more of an integration test (not a unit test), also, in order to do an integration test I would need an external webserver with a url for test purposes (working links and broken links) that will never change (or will only change as the project requires)...because of the coupling of the code making the calls to an api path and the methods not changing the class state and the methods do not return a value (void methods). I can use Moq just to make sure methods are called, BUT that won't really test important output.

Rewriting the class to make it more testable is an option too, which I can do as well.

Side note: the class may have to be changed no matter which option we choose :)

Let me know which route you want to go.

Thanks!