Created
May 15, 2016 22:14
-
-
Save MikeMKH/c107d578d727ba514d05fc8bfa078bb7 to your computer and use it in GitHub Desktop.
FizzBuzz kata in F# using Zip with xUnit and Unquote
This file contains 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
<?xml version="1.0" encoding="utf-8" ?> | |
<configuration> | |
<runtime> | |
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> | |
<dependentAssembly> | |
<assemblyIdentity name="FSharp.Core" | |
publicKeyToken="b03f5f7f11d50a3a" | |
culture="neutral"/> | |
<bindingRedirect oldVersion="4.3.1.0" | |
newVersion="4.4.0.0"/> | |
</dependentAssembly> | |
</assemblyBinding> | |
</runtime> | |
</configuration> |
This file contains 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
namespace FizzBuzz | |
module FizzBuzz = | |
let fizzbuzzer x = | |
let rec fizz = | |
seq { yield "Fizz"; | |
yield ""; yield ""; | |
yield! fizz } | |
let rec buzz = | |
seq { yield "Buzz"; | |
yield ""; yield ""; | |
yield ""; yield ""; | |
yield! buzz } | |
Seq.map2 (+) fizz buzz | |
|> Seq.item (abs x) | |
|> function | |
| "" -> string x | |
| s -> s |
This file contains 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
namespace FizzBuzz.Tests | |
module FizzBuzzTests = | |
open Xunit | |
open Swensen.Unquote | |
open FizzBuzz.FizzBuzz | |
[<Theory>] | |
[<InlineData(1, "1")>] | |
[<InlineData(2, "2")>] | |
[<InlineData(3, "Fizz")>] | |
[<InlineData(33, "Fizz")>] | |
[<InlineData(5, "Buzz")>] | |
[<InlineData(55, "Buzz")>] | |
[<InlineData(15, "FizzBuzz")>] | |
[<InlineData(45, "FizzBuzz")>] | |
let ``given value it must return expected`` value expected = | |
test <@ expected = fizzbuzzer value @> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment