Skip to content

Instantly share code, notes, and snippets.

@vgaltes
Created April 24, 2015 13:37
Show Gist options
  • Select an option

  • Save vgaltes/b9dc646c7a403606af46 to your computer and use it in GitHub Desktop.

Select an option

Save vgaltes/b9dc646c7a403606af46 to your computer and use it in GitHub Desktop.
FSharp FizzBuzz Kata - final code
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