Skip to content

Commit

Permalink
luhn: Replace [<TestCase>] tests with individual tests (#298) (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsbotond authored and ErikSchierboom committed Feb 10, 2017
1 parent 5e18ac6 commit 5755edc
Showing 1 changed file with 103 additions and 9 deletions.
112 changes: 103 additions & 9 deletions exercises/luhn/LuhnTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,106 @@ module LuhnTest

open NUnit.Framework
open Luhn

[<TestCase("1", ExpectedResult = false)>] // single digit strings can not be valid
[<TestCase("0", ExpectedResult = false, Ignore = "Remove to run test case")>] // a single zero is invalid
[<TestCase("046 454 286", ExpectedResult = true, Ignore = "Remove to run test case")>] // valid Canadian SIN
[<TestCase("046 454 287", ExpectedResult = false, Ignore = "Remove to run test case")>] // invalid Canadian SIN
[<TestCase("8273 1232 7352 0569", ExpectedResult = false, Ignore = "Remove to run test case")>] // invalid credit card
[<TestCase("827a 1232 7352 0569", ExpectedResult = false, Ignore = "Remove to run test case")>] // strings that contain non-digits are not valid
let ``Validate checksum`` number =
valid number

[<Test>]
let ``Single digit strings cannot be valid`` () =
let input = "1"
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``A single zero is invalid`` () =
let input = "0"
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Single zero with space is invalid`` () =
let input = "0 "
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Lots of zeros are valid`` () =
let input = "00000"
let expected = true
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Nine doubled is nine`` () =
let input = "091"
let expected = true
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Simple valid number`` () =
let input = " 5 9 "
let expected = true
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Valid Canadian SIN`` () =
let input = "046 454 286"
let expected = true
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Another valid SIN`` () =
let input = "055 444 285"
let expected = true
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Invalid Canadian SIN`` () =
let input = "046 454 287"
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Invalid credit card`` () =
let input = "8273 1232 7352 0569"
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Strings that contain non-digits are not valid`` () =
let input = "827a 1232 7352 0569"
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Punctuation is not allowed`` () =
let input = "055-444-285"
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

[<Test>]
[<Ignore("Remove to run test")>]
let ``Symbols are not allowed`` () =
let input = "055£ 444$ 285"
let expected = false
let actual = valid input
Assert.That(actual, Is.EqualTo(expected))

0 comments on commit 5755edc

Please sign in to comment.