The FizzBuzz test solution contains three projects:
- FizzBuzzLib - where the business logic should be implemented, also contains interfaces
- FizzBuzzLib.Tests - an XUnit project for the main library
- FizzBuzzConsoleApp - Dotnet core console app
There are three interfaces defined:
IFizzBuzz
is the main one, implemented by default. It specifies one method that takes an int and returns a string.IFizzBuzzRange
specifies a method that takes a start int and an end int, and returns an enumerable of strings.IFlexiFizzBuzz
specifies that there should be a dictionary of int and strings, for use in the extended version
The task is to implement the following requirements in a TDD manner:
- Method
FizzBuzzifyAnInt
should return string representation of input integer - Where input is a multiple of 3, method should return "Fizz"
- Where input is a multiple of 5, method should return "Buzz"
- Where input is a multiple of 3 and 5 (e.g. 15), method should return "FizzBuzz"
- Another method should take two integers, "start" and "end", iterate over the range, and return an enumerable of FizzBuzzed strings (implement
IFizzBuzzRange
) - The console app should print the FizzBuzz values for the numbers 0 to 100 (no XUnit test needed, just implement in console app)
The 2nd interviewer will work in a pair with the candidate, delivering the requirements and providing gently assistance as needed.
For certain candidates, we may ask them to additionally implement the following:
- FizzBuzz class to needs implement
IFlexiFizzBuzz
, with the dictionary defaulting to{ {3, "Fizz"}, {5, "Buzz"} }
- Method
FizzBuzzifyAnInt
needs to be modified to use the dictionary - for each dictionary key that the input is a multiple of, return value should include the corresponding string value.
Test cases (1-10):
- Dictionary contains FizzBuzz values. Sequence should be as expected.
- Dictionary contains
{ {2, "Even"} }
. Sequence should be 1, Even, 3, Even, 5, Even, 7, Even, 9, Even - Dictionary contains
{ {2, "Quack"}, {5, "Honk"} }
. Sequence should be 1, Quack, 3, Quack, Honk, Quack, 7, Quack, 9, QuackHonk