Created
April 21, 2015 18:42
-
-
Save SamirTalwar/f4e2e69a35f6201a2f6a to your computer and use it in GitHub Desktop.
FizzBuzz in F# with NUnit
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 FsCheck | |
| 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")>] | |
| [<TestCase(45, "FizzBuzz")>] | |
| let ``the number is fizzedBuzzed``(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