Created
April 24, 2015 13:37
-
-
Save vgaltes/b9dc646c7a403606af46 to your computer and use it in GitHub Desktop.
FSharp FizzBuzz Kata - final code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module FizzBuzz | |
| module Prod = | |
| let fizzBuzz input = | |
| match (input % 3, input % 5) with | |
| | (0, 0) -> "FizzBuzz" | |
| | (0, _) -> "Fizz" | |
| | (_, 0) -> "Buzz" | |
| | (_, _) -> input.ToString() | |
| module Tests = | |
| open Prod | |
| open NUnit.Framework | |
| [<TestCase(1, "1")>] | |
| [<TestCase(2, "2")>] | |
| [<TestCase(3, "Fizz")>] | |
| [<TestCase(4, "4")>] | |
| [<TestCase(5, "Buzz")>] | |
| [<TestCase(6, "Fizz")>] | |
| [<TestCase(9, "Fizz")>] | |
| [<TestCase(10, "Buzz")>] | |
| [<TestCase(15, "FizzBuzz")>] | |
| [<TestCase(30, "FizzBuzz")>] | |
| let ``the number is fizzBuzzed``(number:int, expectedOutput:string) = | |
| Assert.That (fizzBuzz number = expectedOutput) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment