Skip to main content
3 votes
Accepted

Integer index based Union Find with path compression strategy

Using two arrays of int That's nice. There is a tendency to use Node objects that refer to each other by address, which still ...
user555045's user avatar
  • 12.4k
3 votes

Simple HttpClient usage for integration tests in .NET Core

First of all I would like to say that, in my opinion, testing API in a such way is wrong, because how does such unit test behave when: developer machine does not have Internet connection? developer ...
Karol Miszczyk's user avatar
2 votes

Unit tests for a function that calculates demerit points for speeding

You probably want to add a constant for speed 0 create a test for MaxSpeed create a test case for 64 (it's one edge of the partition class ...
Markus Deibel's user avatar
2 votes
Accepted

Unit tests for a function that calculates demerit points for speeding

Am I using too many test cases for CalculateDemeritPoints_WhenCalled_ReturnsExpectedInt? Yes. I'd say so, anyway. Let's say I'm maintaining code you've written. ...
benj2240's user avatar
  • 1,036
2 votes

TDD Supermarket Pricing Kata

I know this is a little old, but the Checkout kata is one of my favorites and I wanted to add my 2 cents. Looking at the original submission and a couple previous answers, I think they are all a ...
Eric's user avatar
  • 21
2 votes

Testing Code That Has Time Delays

Make your code return a Task. Even if you don't await it in the program doesn't mean you can't await it in your test. Also pass in a TimeSpan instead of int for seconds. ...
CharlesNRice's user avatar
  • 4,438
1 vote

Unit Testing - test deletion of archived files

You should create the files in the test setup. Creating and deleting files in the file system takes some time. Using some FS mock / fake will make the test run much faster.
shanif's user avatar
  • 725
1 vote

Unit tests for a function that calculates demerit points for speeding

Since this code is a black box, because it calculates everything itself without calling any dependencies the caller can be aware of, we should test this method with sufficient variations of input to ...
dfhwze's user avatar
  • 14.2k
1 vote

Poker Game: Unit testing different poker hands without violating DRY principles

I decided to post a self-answer as suggested by t3chbot because the following code example is just an attempt at following Simon's suggestion; I haven't fully incorporated the code as I have not ...
asathkum's user avatar
  • 245
1 vote

Poker Game: Unit testing different poker hands without violating DRY principles

IMO I'd join all of your tests into one. And just rotate through them. ...
Peilonrayz's user avatar
  • 44.6k
1 vote
Accepted

Poker Game: Unit testing different poker hands without violating DRY principles

One thing that would help with reducing duplication is to use parameterized tests. Additionally, you might want to have a enum with the different hand types instead of - or in addition to - having ...
Simon Forsberg's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible