Skip to content

Instantly share code, notes, and snippets.

@Codesleuth
Last active August 29, 2015 13:56
Show Gist options
  • Save Codesleuth/9139198 to your computer and use it in GitHub Desktop.
Save Codesleuth/9139198 to your computer and use it in GitHub Desktop.
FizzBuzz in F# (work in progress)
module FizzBuzzFSharp.``FizzBuzz in F#``
open NUnit.Framework
open FsUnit
let fizzbuzz n =
match n with
| n when n % 15 = 0 -> "fizzbuzz"
| n when n % 5 = 0 -> "buzz"
| n when n % 3 = 0 -> "fizz"
| n -> n.ToString()
[<TestFixture>]
type ``Given A Number When Fizzing`` ()=
[<TestCase(1, "1")>]
[<TestCase(2, "2")>]
[<TestCase(4, "4")>]
[<TestCase(7, "7")>] member x.
``when not multiple or 3 or 5 then the number is returned`` input output =
fizzbuzz input |> should equal output
[<TestCase(3)>]
[<TestCase(6)>]
[<TestCase(9)>]
[<TestCase(12)>] member x.
``when multiple of 3 and not 5 then fizz`` (input)=
fizzbuzz input |> should equal "fizz"
[<TestCase(5)>]
[<TestCase(10)>]
[<TestCase(20)>] member x.
``when multiple of 5 and not 3 then buzz`` input =
fizzbuzz input |> should equal "buzz"
[<TestCase(15)>]
[<TestCase(30)>]
[<TestCase(45)>] member x.
``when multiple of 15 then fizzbuzz`` input =
fizzbuzz input |> should equal "fizzbuzz"
@adamwitko
Copy link

Please delete this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment