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
  • 9,994
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
3 votes
Accepted

TDD - Kata - String Calculator

One of my goals when I'm using TDD is to try to clarify the requirements of the system I'm developing. The requirements you're working from have several unclear elements. You've addressed at least ...
forsvarir's user avatar
  • 11.7k
2 votes

Functional tests for a web app repeating the same code

Move your 4 lines into a method with a [TestFixtureSetUp] Attribute. This will run everytime a test is run. See here: http://www.nunit.org/index.php?p=fixtureSetup&r=2.2.10 For example: ...
aydjay's user avatar
  • 663
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

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,026
2 votes
Accepted

Unit-testing event aggregator

The tests should be easy to maintain and understand. That is the tool that drives development. Sometimes it may contradict with the widely known rules you mentioned, but it does not mean we should be ...
Serhii Shushliapin's user avatar
2 votes
Accepted

Proxy test class approach to allow covering legacy code with unit tests

...
t3chb0t's user avatar
  • 44.3k
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,408
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
  • 705
1 vote

REST API wrapper testing

You could simplify entire test class by extracting part responsible for general configuration. Then you can easili split your test into two, first verifying that your ...
yoger's user avatar
  • 283
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
  • 13.9k
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
  • 155
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
  • 43.4k
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
1 vote

Unit Testing Input Class in Monogame

Your tests as they stand aren't great, they are probably adding friction rather than value. That said, it depends a bit on what you're trying to get out of testing in this manner. As an example: <...
forsvarir's user avatar
  • 11.7k

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