Skip to content

Instantly share code, notes, and snippets.

@SamirTalwar
Created April 21, 2015 18:42
Show Gist options
  • Select an option

  • Save SamirTalwar/f4e2e69a35f6201a2f6a to your computer and use it in GitHub Desktop.

Select an option

Save SamirTalwar/f4e2e69a35f6201a2f6a to your computer and use it in GitHub Desktop.
FizzBuzz in F# with NUnit
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