diff --git a/build.fsx b/build.fsx index 5ea8f3d4..a6f4fc7e 100644 --- a/build.fsx +++ b/build.fsx @@ -72,7 +72,7 @@ let (|Fsproj|Csproj|Vbproj|) (projFileName: string) = | f when f.EndsWith("fsproj") -> Fsproj | f when f.EndsWith("csproj") -> Csproj | f when f.EndsWith("vbproj") -> Vbproj - | _ -> failwith (sprintf "Project file %s not supported. Unknown project type." projFileName) + | _ -> failwith $"Project file %s{projFileName} not supported. Unknown project type." // Generate assembly info files with the right version & up-to-date information Target.create "AssemblyInfo" (fun _ -> @@ -141,7 +141,7 @@ Target.create "CheckFormat" (fun _ -> elif result.ExitCode = 99 then failwith "Some files need formatting, check output for more info" else - Trace.logf "Errors while formatting: %A" result.Errors) + Trace.logf $"Errors while formatting: %A{result.Errors}") Target.create "Format" (fun _ -> let result = @@ -151,7 +151,7 @@ Target.create "Format" (fun _ -> |> DotNet.exec id "fantomas" if not result.OK then - printfn "Errors while formatting all files: %A" result.Messages) + printfn $"Errors while formatting all files: %A{result.Messages}") // -------------------------------------------------------------------------------------- // Build library & test project @@ -169,19 +169,19 @@ Target.create "NUnit" (fun _ -> let result = DotNet.exec id "test" "tests/FsUnit.NUnit.Test/" if not result.OK then - failwithf "NUnit test failed: %A" result.Errors) + failwithf $"NUnit test failed: %A{result.Errors}") Target.create "xUnit" (fun _ -> let result = DotNet.exec id "test" "tests/FsUnit.Xunit.Test/" if not result.OK then - failwithf "xUnit test failed: %A" result.Errors) + failwithf $"xUnit test failed: %A{result.Errors}") Target.create "MsTest" (fun _ -> let result = DotNet.exec id "test" "tests/FsUnit.MsTest.Test/" if not result.OK then - failwithf "MsTest test failed: %A" result.Errors) + failwithf $"MsTest test failed: %A{result.Errors}") Target.create "RunTests" ignore diff --git a/src/Common.fs b/src/Common.fs index 96fa03e8..bc1c7f96 100644 --- a/src/Common.fs +++ b/src/Common.fs @@ -26,7 +26,7 @@ module Common = | _ -> None /// - /// Checks wether the given value is of the same case of a union type as the + /// Checks whether the given value is of the same case of a union type as the /// case defined by the given expression. /// /// If the expression is not an union case or does not result in an union case. @@ -37,7 +37,7 @@ module Common = | Lambda(_, expr) | Let(_, _, expr) -> isOfCase expr | NewUnionCase(case, _) -> - // Returns a function that check wether the tag of the argument matches + // Returns a function that check whether the tag of the argument matches // the tag of the union given in the expression. let readTag = FSharpValue.PreComputeUnionTagReader case.DeclaringType diff --git a/src/FsUnit.MsTestUnit/FsUnit.fs b/src/FsUnit.MsTestUnit/FsUnit.fs index 93e13f63..cf34b978 100644 --- a/src/FsUnit.MsTestUnit/FsUnit.fs +++ b/src/FsUnit.MsTestUnit/FsUnit.fs @@ -14,9 +14,9 @@ let inline private assertThat(actual, matcher: IMatcher<'a>) = raise(AssertFailedException($"%A{description} was %A{value}", null)) match box actual with - | :? (unit -> unit) as actualfunc -> + | :? (unit -> unit) as actualFunc -> (try - actualfunc() + actualFunc() String.Empty with ex -> ex.ToString()) diff --git a/src/FsUnit.NUnit/CustomConstraints.fs b/src/FsUnit.NUnit/CustomConstraints.fs index a61ac3ea..79d723fb 100644 --- a/src/FsUnit.NUnit/CustomConstraints.fs +++ b/src/FsUnit.NUnit/CustomConstraints.fs @@ -17,6 +17,4 @@ module CustomConstraints = let result = Common.isOfCase this.Expected actual ConstraintResult(this, actual, result) else - let actualType = actual.GetType() - do printf $"Got a {actualType.Name}" - failwith "Value (not expression) is not a union case." + failwith $"Value (not expression) is not a union case. Got a {actual.GetType().Name}." diff --git a/src/FsUnit.NUnit/FsUnitTyped.fs b/src/FsUnit.NUnit/FsUnitTyped.fs index 423732a7..7c956ee2 100644 --- a/src/FsUnit.NUnit/FsUnitTyped.fs +++ b/src/FsUnit.NUnit/FsUnitTyped.fs @@ -2,7 +2,6 @@ namespace FsUnitTyped open System.Diagnostics open NUnit.Framework -open NUnit.Framework.Legacy [] module TopLevelOperators = @@ -17,23 +16,23 @@ module TopLevelOperators = [] let shouldContain (expected: 'a) (actual: 'a seq) = - CollectionAssert.Contains(actual, expected) + Assert.That(actual, Does.Contain(expected)) [] let shouldBeEmpty(actual: 'a seq) = - ClassicAssert.IsEmpty(actual) + Assert.That(actual, Is.Empty) [] let shouldNotContain (expected: 'a) (actual: 'a seq) = - CollectionAssert.DoesNotContain(actual, expected, $"Seq %A{actual} should not contain %A{expected}") + Assert.That(actual, Does.Not.Contain(expected), $"Seq %A{actual} should not contain %A{expected}") [] let shouldBeSmallerThan (expected: 'a) (actual: 'a) = - ClassicAssert.Less(actual, expected) + Assert.That(actual, Is.LessThan(expected)) [] let shouldBeGreaterThan (expected: 'a) (actual: 'a) = - ClassicAssert.Greater(actual, expected) + Assert.That(actual, Is.GreaterThan(expected)) [] let shouldFail<'exn when 'exn :> exn>(f: unit -> unit) = @@ -41,11 +40,11 @@ module TopLevelOperators = [] let shouldContainText (expected: string) (actual: string) = - StringAssert.Contains(expected, actual) + Assert.That(actual, Does.Contain(expected)) [] let shouldNotContainText (expected: string) (actual: string) = - StringAssert.DoesNotContain(expected, actual) + Assert.That(actual, Does.Not.Contain(expected)) [] let shouldHaveLength (expected: int) actual = diff --git a/src/FsUnit.Xunit/CustomMatchers.fs b/src/FsUnit.Xunit/CustomMatchers.fs index c971e528..760cfbe3 100644 --- a/src/FsUnit.Xunit/CustomMatchers.fs +++ b/src/FsUnit.Xunit/CustomMatchers.fs @@ -40,8 +40,8 @@ let equalWithin (tolerance: obj) (expected: obj) = let matches(actual: obj) = let parseValue(v: string) = match Double.TryParse(v, NumberStyles.Any, CultureInfo("en-US")) with - | (true, x) -> Some(x) - | (false, _) -> None + | true, x -> Some(x) + | false, _ -> None let actual = string actual |> parseValue let expect = string expected |> parseValue @@ -185,10 +185,10 @@ let instanceOfType<'a> = let contain expected = let matches(actual: obj) = match actual with - | :? (list<_>) as l -> l |> List.exists(fun i -> i = expected) - | :? (array<_>) as a -> a |> Array.exists(fun i -> i = expected) - | :? (seq<_>) as s -> s |> Seq.exists(fun i -> i = expected) - | :? IEnumerable as e -> e |> Seq.cast |> Seq.exists(fun i -> i = expected) + | :? list<_> as l -> l |> List.exists((=) expected) + | :? array<_> as a -> a |> Array.exists((=) expected) + | :? seq<_> as s -> s |> Seq.exists((=) expected) + | :? IEnumerable as e -> e |> Seq.cast |> Seq.exists((=) expected) | _ -> false CustomMatcher($"Contains %A{expected}", Func<_, _> matches) @@ -213,17 +213,6 @@ let haveLength expected = let haveCount expected = CustomMatcher($"Have Count %d{expected}", (fun x -> x?Count = expected)) -let containf f = - let matches(actual: obj) = - match actual with - | :? (list<_>) as l -> l |> List.exists f - | :? (array<_>) as a -> a |> Array.exists f - | :? (seq<_>) as s -> s |> Seq.exists f - | :? IEnumerable as e -> e |> Seq.cast |> Seq.exists f - | _ -> false - - CustomMatcher($"Contains %A{f}", Func<_, _> matches) - let supersetOf expected = CustomMatcher($"Is superset of %A{expected}", (fun c -> Set.isSuperset (Set(unbox c)) (Set expected))) @@ -233,7 +222,7 @@ let subsetOf expected = let matchList xs = let matches(ys: obj) = match ys with - | :? (list<_>) as ys' -> List.sort xs = List.sort ys' + | :? list<_> as ys' -> List.sort xs = List.sort ys' | :? IEnumerable as e -> e |> Seq.cast |> Seq.isEmpty && xs |> Seq.isEmpty | _ -> false @@ -242,9 +231,9 @@ let matchList xs = let private makeOrderedMatcher description comparer = let matches(actual: obj) = match actual with - | :? (list) as l -> l = List.sortWith comparer l - | :? (array) as a -> a = Array.sortWith comparer a - | :? (seq) as s -> + | :? list as l -> l = List.sortWith comparer l + | :? array as a -> a = Array.sortWith comparer a + | :? seq as s -> let a = s |> Seq.toArray a = (a |> Array.sortWith comparer) | :? IEnumerable as e -> @@ -262,52 +251,51 @@ type ChoiceDiscriminator(n: int) = member this.check(c: Choice<'a, 'b>) : bool = match c with - | Choice1Of2(_) -> n = 1 - | Choice2Of2(_) -> n = 2 + | Choice1Of2 _ -> n = 1 + | Choice2Of2 _ -> n = 2 member this.check(c: Choice<'a, 'b, 'c>) : bool = match c with - | Choice1Of3(_) -> n = 1 - | Choice2Of3(_) -> n = 2 - | Choice3Of3(_) -> n = 3 + | Choice1Of3 _ -> n = 1 + | Choice2Of3 _ -> n = 2 + | Choice3Of3 _ -> n = 3 member this.check(c: Choice<'a, 'b, 'c, 'd>) : bool = match c with - | Choice1Of4(_) -> n = 1 - | Choice2Of4(_) -> n = 2 - | Choice3Of4(_) -> n = 3 - | Choice4Of4(_) -> n = 4 + | Choice1Of4 _ -> n = 1 + | Choice2Of4 _ -> n = 2 + | Choice3Of4 _ -> n = 3 + | Choice4Of4 _ -> n = 4 member this.check(c: Choice<'a, 'b, 'c, 'd, 'e>) : bool = match c with - | Choice1Of5(_) -> n = 1 - | Choice2Of5(_) -> n = 2 - | Choice3Of5(_) -> n = 3 - | Choice4Of5(_) -> n = 4 - | Choice5Of5(_) -> n = 5 + | Choice1Of5 _ -> n = 1 + | Choice2Of5 _ -> n = 2 + | Choice3Of5 _ -> n = 3 + | Choice4Of5 _ -> n = 4 + | Choice5Of5 _ -> n = 5 member this.check(c: Choice<'a, 'b, 'c, 'd, 'e, 'f>) : bool = match c with - | Choice1Of6(_) -> n = 1 - | Choice2Of6(_) -> n = 2 - | Choice3Of6(_) -> n = 3 - | Choice4Of6(_) -> n = 4 - | Choice5Of6(_) -> n = 5 - | Choice6Of6(_) -> n = 6 + | Choice1Of6 _ -> n = 1 + | Choice2Of6 _ -> n = 2 + | Choice3Of6 _ -> n = 3 + | Choice4Of6 _ -> n = 4 + | Choice5Of6 _ -> n = 5 + | Choice6Of6 _ -> n = 6 member this.check(c: Choice<'a, 'b, 'c, 'd, 'e, 'f, 'g>) : bool = match c with - | Choice1Of7(_) -> n = 1 - | Choice2Of7(_) -> n = 2 - | Choice3Of7(_) -> n = 3 - | Choice4Of7(_) -> n = 4 - | Choice5Of7(_) -> n = 5 - | Choice6Of7(_) -> n = 6 - | Choice7Of7(_) -> n = 7 + | Choice1Of7 _ -> n = 1 + | Choice2Of7 _ -> n = 2 + | Choice3Of7 _ -> n = 3 + | Choice4Of7 _ -> n = 4 + | Choice5Of7 _ -> n = 5 + | Choice6Of7 _ -> n = 6 + | Choice7Of7 _ -> n = 7 member this.check(c: obj) : bool = - let cType = c.GetType() - let cArgs = cType.GetGenericArguments() + let cArgs = c.GetType().GetGenericArguments() let cArgCount = Seq.length cArgs try @@ -318,7 +306,7 @@ type ChoiceDiscriminator(n: int) = false let choice n = - CustomMatcher($"The choice %d{n}", (fun x -> (ChoiceDiscriminator(n)).check(x))) + CustomMatcher($"The choice %d{n}", (fun x -> ChoiceDiscriminator(n).check(x))) let inRange min max = let matches(actual: obj) = @@ -329,8 +317,7 @@ let inRange min max = let ofCase(case: Quotations.Expr) = let expected = - case |> Common.caseName |> defaultArg - <| "" + defaultArg (Common.caseName case) "" let matcher = CustomMatcher(expected, (fun x -> x |> Common.isOfCase case)) diff --git a/src/FsUnit.Xunit/FsUnit.fs b/src/FsUnit.Xunit/FsUnit.fs index 6a562dbd..4165fa87 100644 --- a/src/FsUnit.Xunit/FsUnit.fs +++ b/src/FsUnit.Xunit/FsUnit.fs @@ -6,7 +6,7 @@ open Xunit.Sdk open NHamcrest open NHamcrest.Core -type Xunit.Assert with +type Assert with static member That<'a>(actual, matcher: IMatcher<'a>) = if not(matcher.Matches(actual)) then @@ -17,9 +17,9 @@ type Xunit.Assert with raise(EqualException.ForMismatchedValues(description.ToString(), value)) match box actual with - | :? (unit -> unit) as actualfunc -> + | :? (unit -> unit) as actualFunc -> (try - actualfunc() + actualFunc() String.Empty with ex -> ex.ToString()) diff --git a/src/FsUnit.Xunit/FsUnitTyped.fs b/src/FsUnit.Xunit/FsUnitTyped.fs index 178e1e36..bd16638a 100644 --- a/src/FsUnit.Xunit/FsUnitTyped.fs +++ b/src/FsUnit.Xunit/FsUnitTyped.fs @@ -7,14 +7,10 @@ open FsUnit.Xunit [] module TopLevelOperators = - /// Asserts that `expected` is equal to `actual`. - /// The equality instance on `actual` is used, if available. [] let shouldEqual<'a> (expected: 'a) (actual: 'a) = actual |> should equal expected - /// Asserts that `expected` is not equal to `actual`. - /// The equality instance on `actual` is used, if available. [] let shouldNotEqual<'a> (expected: 'a) (actual: 'a) = actual |> should not' (equal expected) diff --git a/tests/FsUnit.MsTest.Test/FsUnit.MsTest.Test.fsproj b/tests/FsUnit.MsTest.Test/FsUnit.MsTest.Test.fsproj index 94f8a21b..b97767c5 100644 --- a/tests/FsUnit.MsTest.Test/FsUnit.MsTest.Test.fsproj +++ b/tests/FsUnit.MsTest.Test/FsUnit.MsTest.Test.fsproj @@ -5,7 +5,7 @@ true - + @@ -37,7 +37,7 @@ - + diff --git a/tests/FsUnit.MsTest.Test/NaNTests.fs b/tests/FsUnit.MsTest.Test/beNaNTests.fs similarity index 95% rename from tests/FsUnit.MsTest.Test/NaNTests.fs rename to tests/FsUnit.MsTest.Test/beNaNTests.fs index 5463d170..0b9d503f 100644 --- a/tests/FsUnit.MsTest.Test/NaNTests.fs +++ b/tests/FsUnit.MsTest.Test/beNaNTests.fs @@ -5,7 +5,7 @@ open FsUnit.MsTest open System [] -type ``NotANumberTests``() = +type ``beNaNTests``() = [] member _.``Number 1 should be a number``() = diff --git a/tests/FsUnit.MsTest.Test/ofCaseTests.fs b/tests/FsUnit.MsTest.Test/beOfCaseTests.fs similarity index 98% rename from tests/FsUnit.MsTest.Test/ofCaseTests.fs rename to tests/FsUnit.MsTest.Test/beOfCaseTests.fs index a398185e..e92af232 100644 --- a/tests/FsUnit.MsTest.Test/ofCaseTests.fs +++ b/tests/FsUnit.MsTest.Test/beOfCaseTests.fs @@ -9,7 +9,7 @@ type TestUnion = | Third of string [] -type ``ofCaseTests``() = +type ``beOfCaseTests``() = [] member _.``Given a (parameterless) union case of matching case returns true``() = diff --git a/tests/FsUnit.MsTest.Test/beUniqueTests.fs b/tests/FsUnit.MsTest.Test/beUniqueTests.fs index 75e7ca2a..c046e2c6 100644 --- a/tests/FsUnit.MsTest.Test/beUniqueTests.fs +++ b/tests/FsUnit.MsTest.Test/beUniqueTests.fs @@ -4,7 +4,7 @@ open Microsoft.VisualStudio.TestTools.UnitTesting open FsUnit.MsTest [] -type ``haveUniqueTests``() = +type ``beUniqueTests``() = [] member _.``empty list should be considered as unique``() = diff --git a/tests/FsUnit.MsTest.Test/equalTests.fs b/tests/FsUnit.MsTest.Test/equalTests.fs index ec328efd..cc5ffad8 100644 --- a/tests/FsUnit.MsTest.Test/equalTests.fs +++ b/tests/FsUnit.MsTest.Test/equalTests.fs @@ -98,10 +98,14 @@ type ``equalTests``() = member _.``None should equal None``() = None |> should equal None + [] + member _.``None should equal null``() = + None |> should equal null + [] member _.``Ok "foo" should fail on equal Ok "bar" but message should be equal``() = (fun () -> Ok "foo" |> should equal (Ok "bar")) - |> fun f -> Assert.ThrowsException(f) + |> Assert.ThrowsException |> fun e -> e.Message |> should equal ("Equals Ok \"bar\" was Ok \"foo\"") diff --git a/tests/FsUnit.NUnit.Test/FsUnit.NUnit.Test.fsproj b/tests/FsUnit.NUnit.Test/FsUnit.NUnit.Test.fsproj index 12b1ebba..fc068c80 100644 --- a/tests/FsUnit.NUnit.Test/FsUnit.NUnit.Test.fsproj +++ b/tests/FsUnit.NUnit.Test/FsUnit.NUnit.Test.fsproj @@ -5,39 +5,38 @@ - - + + + + + + + + + - - - - - - - - + + + - - - diff --git a/tests/FsUnit.NUnit.Test/beAscendingTests.fs b/tests/FsUnit.NUnit.Test/beAscendingTests.fs index be0d39ef..25d5efb4 100644 --- a/tests/FsUnit.NUnit.Test/beAscendingTests.fs +++ b/tests/FsUnit.NUnit.Test/beAscendingTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be ascending tests``() = + [] member _.``Empty list should be ascending``() = [] |> should be ascending diff --git a/tests/FsUnit.NUnit.Test/beDescendingTests.fs b/tests/FsUnit.NUnit.Test/beDescendingTests.fs index 1be66b33..eb742b81 100644 --- a/tests/FsUnit.NUnit.Test/beDescendingTests.fs +++ b/tests/FsUnit.NUnit.Test/beDescendingTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be descending tests``() = + [] member _.``Empty list should be descending``() = [] |> should be descending diff --git a/tests/FsUnit.NUnit.Test/beEmptyStringTests.fs b/tests/FsUnit.NUnit.Test/beEmptyStringTests.fs index d08321ad..4f640912 100644 --- a/tests/FsUnit.NUnit.Test/beEmptyStringTests.fs +++ b/tests/FsUnit.NUnit.Test/beEmptyStringTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be EmptyString tests``() = + [] member _.``empty string should be EmptyString``() = "" |> should be EmptyString diff --git a/tests/FsUnit.NUnit.Test/beEmptyTests.fs b/tests/FsUnit.NUnit.Test/beEmptyTests.fs index 5052e413..6efbdb49 100644 --- a/tests/FsUnit.NUnit.Test/beEmptyTests.fs +++ b/tests/FsUnit.NUnit.Test/beEmptyTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be Empty tests``() = + [] member _.``empty List should be Empty``() = [] |> should be Empty diff --git a/tests/FsUnit.NUnit.Test/beFalseTests.fs b/tests/FsUnit.NUnit.Test/beFalseTests.fs index 8f286d4a..4aa2c0ef 100644 --- a/tests/FsUnit.NUnit.Test/beFalseTests.fs +++ b/tests/FsUnit.NUnit.Test/beFalseTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be False tests``() = + [] member _.``false should be False``() = false |> should be False diff --git a/tests/FsUnit.NUnit.Test/beGreaterThanOrEqualTo.fs b/tests/FsUnit.NUnit.Test/beGreaterThanOrEqualTo.fs index e4fc52fe..e09cb9c4 100644 --- a/tests/FsUnit.NUnit.Test/beGreaterThanOrEqualTo.fs +++ b/tests/FsUnit.NUnit.Test/beGreaterThanOrEqualTo.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be greaterThanOrEqualTo tests``() = + [] member _.``11 should be greater than 10``() = 11 |> should be (greaterThanOrEqualTo 10) diff --git a/tests/FsUnit.NUnit.Test/beGreaterThanTests.fs b/tests/FsUnit.NUnit.Test/beGreaterThanTests.fs index d413f0f5..dd4852c6 100644 --- a/tests/FsUnit.NUnit.Test/beGreaterThanTests.fs +++ b/tests/FsUnit.NUnit.Test/beGreaterThanTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be greaterThan tests``() = + [] member _.``11 should be greater than 10``() = 11 |> should be (greaterThan 10) diff --git a/tests/FsUnit.NUnit.Test/beInRangeTests.fs b/tests/FsUnit.NUnit.Test/beInRangeTests.fs index 24039894..43d38bec 100644 --- a/tests/FsUnit.NUnit.Test/beInRangeTests.fs +++ b/tests/FsUnit.NUnit.Test/beInRangeTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be inRange tests``() = + [] member _.``25 should be in range from 5 to 30``() = 25 |> should be (inRange 5 30) diff --git a/tests/FsUnit.NUnit.Test/beLessThanOrEqualToTests.fs b/tests/FsUnit.NUnit.Test/beLessThanOrEqualToTests.fs index 214919df..1fa14905 100644 --- a/tests/FsUnit.NUnit.Test/beLessThanOrEqualToTests.fs +++ b/tests/FsUnit.NUnit.Test/beLessThanOrEqualToTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be lessThanOrEqualTo tests``() = + [] member _.``10 should be less than 11``() = 10 |> should be (lessThanOrEqualTo 11) diff --git a/tests/FsUnit.NUnit.Test/beLessThanTests.fs b/tests/FsUnit.NUnit.Test/beLessThanTests.fs index 170726a5..afbe4102 100644 --- a/tests/FsUnit.NUnit.Test/beLessThanTests.fs +++ b/tests/FsUnit.NUnit.Test/beLessThanTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be lessThan tests``() = + [] member _.``10 should be less than 11``() = 10 |> should be (lessThan 11) diff --git a/tests/FsUnit.NUnit.Test/NaNTests.fs b/tests/FsUnit.NUnit.Test/beNaNTests.fs similarity index 94% rename from tests/FsUnit.NUnit.Test/NaNTests.fs rename to tests/FsUnit.NUnit.Test/beNaNTests.fs index d903acfe..bdb4ef42 100644 --- a/tests/FsUnit.NUnit.Test/NaNTests.fs +++ b/tests/FsUnit.NUnit.Test/beNaNTests.fs @@ -5,7 +5,8 @@ open FsUnit open System [] -type ``Not a Number tests``() = +type ``be NaN tests``() = + [] member _.``Number 1 should be a number``() = 1 |> should not' (be NaN) diff --git a/tests/FsUnit.NUnit.Test/beNullOrEmptyStringTests.fs b/tests/FsUnit.NUnit.Test/beNullOrEmptyStringTests.fs index cd5ffd95..a75bff30 100644 --- a/tests/FsUnit.NUnit.Test/beNullOrEmptyStringTests.fs +++ b/tests/FsUnit.NUnit.Test/beNullOrEmptyStringTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be NullOrEmptyString tests``() = + [] member _.``empty string should be NullOrEmptyString``() = "" |> should be NullOrEmptyString diff --git a/tests/FsUnit.NUnit.Test/beNullTests.fs b/tests/FsUnit.NUnit.Test/beNullTests.fs index e1f33a5c..148fcaf1 100644 --- a/tests/FsUnit.NUnit.Test/beNullTests.fs +++ b/tests/FsUnit.NUnit.Test/beNullTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be Null tests``() = + [] member _.``null should be Null``() = null |> should be Null diff --git a/tests/FsUnit.NUnit.Test/ofCaseTests.fs b/tests/FsUnit.NUnit.Test/beOfCaseTests.fs similarity index 95% rename from tests/FsUnit.NUnit.Test/ofCaseTests.fs rename to tests/FsUnit.NUnit.Test/beOfCaseTests.fs index acd25fbb..69a93834 100644 --- a/tests/FsUnit.NUnit.Test/ofCaseTests.fs +++ b/tests/FsUnit.NUnit.Test/beOfCaseTests.fs @@ -2,7 +2,6 @@ namespace FsUnit.Test open NUnit.Framework open FsUnit -open FsUnit.CustomConstraints type TestUnion = | First @@ -10,7 +9,7 @@ type TestUnion = | Third of string [] -type ``ofCase tests``() = +type ``be ofCase tests``() = [] member _.``Given a (parameterless) union case of matching case returns true``() = @@ -44,7 +43,7 @@ type ``ofCase tests``() = [] member _.``Given a non-union case as value argument throws an exception``() = (fun () -> 5 |> should not' (be ofCase <@ Second 5 @>) |> ignore) - |> should (throwWithMessage "Value (not expression) is not a union case.") typeof + |> should (throwWithMessage "Value (not expression) is not a union case. Got a Int32.") typeof [] member _.``None should be ofCase None``() = diff --git a/tests/FsUnit.NUnit.Test/beOfExactTypeTests.fs b/tests/FsUnit.NUnit.Test/beOfExactTypeTests.fs index 8b379885..d572de8e 100644 --- a/tests/FsUnit.NUnit.Test/beOfExactTypeTests.fs +++ b/tests/FsUnit.NUnit.Test/beOfExactTypeTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``should be of exact type tests``() = +type ``be ofExactType tests``() = + [] member _.``empty string should be of exact type String``() = "" |> should be ofExactType diff --git a/tests/FsUnit.NUnit.Test/beSameAsTests.fs b/tests/FsUnit.NUnit.Test/beSameAsTests.fs index 839cf67e..e63fd4ba 100644 --- a/tests/FsUnit.NUnit.Test/beSameAsTests.fs +++ b/tests/FsUnit.NUnit.Test/beSameAsTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``be SameAs tests``() = +type ``be sameAs tests``() = + let anObj = obj() let otherObj = obj() diff --git a/tests/FsUnit.NUnit.Test/beTrueTests.fs b/tests/FsUnit.NUnit.Test/beTrueTests.fs index f79c7bee..def05aca 100644 --- a/tests/FsUnit.NUnit.Test/beTrueTests.fs +++ b/tests/FsUnit.NUnit.Test/beTrueTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``be True tests``() = + [] member _.``true should be True``() = true |> should be True diff --git a/tests/FsUnit.NUnit.Test/beUniqueTests.fs b/tests/FsUnit.NUnit.Test/beUniqueTests.fs index 295d8855..51e9692e 100644 --- a/tests/FsUnit.NUnit.Test/beUniqueTests.fs +++ b/tests/FsUnit.NUnit.Test/beUniqueTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``have unique items list tests``() = +type ``be unique tests``() = + [] member _.``empty list should be considered as unique``() = [] |> should be unique diff --git a/tests/FsUnit.NUnit.Test/containTests.fs b/tests/FsUnit.NUnit.Test/containTests.fs index 13ff6643..e1219d84 100644 --- a/tests/FsUnit.NUnit.Test/containTests.fs +++ b/tests/FsUnit.NUnit.Test/containTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``contain tests``() = + [] member _.``List with item should contain item``() = [ 1 ] |> should contain 1 diff --git a/tests/FsUnit.NUnit.Test/shouldEndWithTests.fs b/tests/FsUnit.NUnit.Test/endWithTests.fs similarity index 91% rename from tests/FsUnit.NUnit.Test/shouldEndWithTests.fs rename to tests/FsUnit.NUnit.Test/endWithTests.fs index 06845905..4a29b759 100644 --- a/tests/FsUnit.NUnit.Test/shouldEndWithTests.fs +++ b/tests/FsUnit.NUnit.Test/endWithTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``should endWith tests``() = +type ``endWith tests``() = + [] member _.``empty string should end with ""``() = "" |> should endWith "" diff --git a/tests/FsUnit.NUnit.Test/equalTests.fs b/tests/FsUnit.NUnit.Test/equalTests.fs index 72dd937b..bbe2f8dd 100644 --- a/tests/FsUnit.NUnit.Test/equalTests.fs +++ b/tests/FsUnit.NUnit.Test/equalTests.fs @@ -1,6 +1,5 @@ namespace FsUnit.Test -open System.Collections open System.Collections.Immutable open NUnit.Framework @@ -19,6 +18,7 @@ type NeverEqual() = [] type ``equal Tests``() = + let anObj = obj() let otherObj = obj() let anImmutableArray = ImmutableArray.Create(1, 2, 3) @@ -105,6 +105,10 @@ type ``equal Tests``() = member _.``None should equal None``() = None |> should equal None + [] + member _.``None should equal null``() = + None |> should equal null + [] member _.``Ok "ok" should equal Ok "no" should fail but message should be equal``() = (fun () -> [ Ok "ok" ] |> should equal [ Ok "no" ]) diff --git a/tests/FsUnit.NUnit.Test/equalWithinTests.fs b/tests/FsUnit.NUnit.Test/equalWithinTests.fs index b236964c..94055e45 100644 --- a/tests/FsUnit.NUnit.Test/equalWithinTests.fs +++ b/tests/FsUnit.NUnit.Test/equalWithinTests.fs @@ -3,10 +3,9 @@ namespace FsUnit.Test open NUnit.Framework open FsUnit -(* Thanks to erdoll for this suggestion: https://fsunit.codeplex.com/discussions/269320 *) - [] type ``equalWithin tests``() = + [] member _.``should equal within tolerance``() = 10.1 |> should (equalWithin 0.1) 10.11 diff --git a/tests/FsUnit.NUnit.Test/genericAssertTests.fs b/tests/FsUnit.NUnit.Test/genericAssertTests.fs index 76182887..34906f1a 100644 --- a/tests/FsUnit.NUnit.Test/genericAssertTests.fs +++ b/tests/FsUnit.NUnit.Test/genericAssertTests.fs @@ -18,6 +18,7 @@ type NeverEqual() = [] type ``areEqual Tests``() = + let anObj = obj() let otherObj = obj() let anImmutableArray = ImmutableArray.Create(1, 2, 3) @@ -66,6 +67,7 @@ type ``areEqual Tests``() = [] type ``areNotEqual Tests``() = + let anObj = obj() let otherObj = obj() let anImmutableArray = ImmutableArray.Create(1, 2, 3) @@ -105,6 +107,7 @@ type ``areNotEqual Tests``() = [] type ``areSame tests``() = + let anObj = obj() let otherObj = obj() @@ -118,6 +121,7 @@ type ``areSame tests``() = [] type ``areNotSame tests``() = + let anObj = obj() let otherObj = obj() @@ -131,6 +135,7 @@ type ``areNotSame tests``() = [] type ``contains tests``() = + [] member _.``List with item should contain item``() = Assert.Contains(1, [ 1 ]) @@ -157,6 +162,7 @@ type ``contains tests``() = [] type ``greater tests``() = + [] member _.``11 should be greater than 10``() = Assert.Greater(11, 10) @@ -179,6 +185,7 @@ type ``greater tests``() = [] type ``greaterOrEqual tests``() = + [] member _.``11 should be greater than 10``() = Assert.GreaterOrEqual(11, 10) @@ -205,6 +212,7 @@ type ``greaterOrEqual tests``() = [] type ``less tests``() = + [] member _.``10 should be less than 11``() = Assert.Less(10, 11) @@ -227,6 +235,7 @@ type ``less tests``() = [] type ``lessOrEqual tests``() = + [] member _.``10 should be less than 11``() = Assert.LessOrEqual(10, 11) @@ -249,6 +258,7 @@ type ``lessOrEqual tests``() = [] type ``null tests``() = + [] member _.``null should be Null``() = Assert.Null(null) @@ -259,6 +269,7 @@ type ``null tests``() = [] type ``notNull tests``() = + [] member _.``non-null should not be Null``() = Assert.NotNull("something") diff --git a/tests/FsUnit.NUnit.Test/haveCountTests.fs b/tests/FsUnit.NUnit.Test/haveCountTests.fs index 787c6ad4..38a3ff98 100644 --- a/tests/FsUnit.NUnit.Test/haveCountTests.fs +++ b/tests/FsUnit.NUnit.Test/haveCountTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``have Count tests``() = +type ``haveCount tests``() = + let emptyList = System.Collections.Generic.List() let singleItemList = System.Collections.Generic.List() diff --git a/tests/FsUnit.NUnit.Test/haveLengthTests.fs b/tests/FsUnit.NUnit.Test/haveLengthTests.fs index 175fcd45..0cfbb4ee 100644 --- a/tests/FsUnit.NUnit.Test/haveLengthTests.fs +++ b/tests/FsUnit.NUnit.Test/haveLengthTests.fs @@ -5,6 +5,7 @@ open FsUnit [] type ``haveLength tests``() = + // F# List [] member _.``List with 1 item should have Length 1``() = diff --git a/tests/FsUnit.NUnit.Test/shouldHaveSubstringTests.fs b/tests/FsUnit.NUnit.Test/haveSubstringTests.fs similarity index 90% rename from tests/FsUnit.NUnit.Test/shouldHaveSubstringTests.fs rename to tests/FsUnit.NUnit.Test/haveSubstringTests.fs index 03c14b99..3ab38988 100644 --- a/tests/FsUnit.NUnit.Test/shouldHaveSubstringTests.fs +++ b/tests/FsUnit.NUnit.Test/haveSubstringTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``should haveSubstring tests``() = +type ``haveSubstring tests``() = + [] member _.``empty string should contain ""``() = "" |> should haveSubstring "" diff --git a/tests/FsUnit.NUnit.Test/instanceOfTests.fs b/tests/FsUnit.NUnit.Test/instanceOfTests.fs index 925211d5..81b929f7 100644 --- a/tests/FsUnit.NUnit.Test/instanceOfTests.fs +++ b/tests/FsUnit.NUnit.Test/instanceOfTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``Instance Of tests``() = +type ``instanceOfType tests``() = + [] member _.``int should be instance of type Object``() = 1 |> should be instanceOfType diff --git a/tests/FsUnit.NUnit.Test/raiseTests.fs b/tests/FsUnit.NUnit.Test/raiseTests.fs index 0aa369e4..99b3153f 100644 --- a/tests/FsUnit.NUnit.Test/raiseTests.fs +++ b/tests/FsUnit.NUnit.Test/raiseTests.fs @@ -11,6 +11,7 @@ type ApplicationException(msg: string) = [] type ``raise tests``() = + [] member _.``should pass when exception of expected type is thrown``() = (fun () -> raise TestException) |> should throw typeof diff --git a/tests/FsUnit.NUnit.Test/shouldFailTests.fs b/tests/FsUnit.NUnit.Test/shouldFailTests.fs index 0f0d48aa..aee5c10e 100644 --- a/tests/FsUnit.NUnit.Test/shouldFailTests.fs +++ b/tests/FsUnit.NUnit.Test/shouldFailTests.fs @@ -6,6 +6,7 @@ open FsUnit [] type ``shouldFail tests``() = + [] member _.``empty List should fail to contain item``() = shouldFail(fun () -> [] |> should contain 1) diff --git a/tests/FsUnit.NUnit.Test/shouldStartWithTests.fs b/tests/FsUnit.NUnit.Test/startWithTests.fs similarity index 91% rename from tests/FsUnit.NUnit.Test/shouldStartWithTests.fs rename to tests/FsUnit.NUnit.Test/startWithTests.fs index 2d6ecb2e..05fe7dac 100644 --- a/tests/FsUnit.NUnit.Test/shouldStartWithTests.fs +++ b/tests/FsUnit.NUnit.Test/startWithTests.fs @@ -4,7 +4,8 @@ open NUnit.Framework open FsUnit [] -type ``should startWith tests``() = +type ``startWith tests``() = + [] member _.``empty string should start with ""``() = "" |> should startWith "" diff --git a/tests/FsUnit.NUnit.Test/typed.beEmptyTests.fs b/tests/FsUnit.NUnit.Test/typed.beEmptyTests.fs index a4e4071a..50ba28ce 100644 --- a/tests/FsUnit.NUnit.Test/typed.beEmptyTests.fs +++ b/tests/FsUnit.NUnit.Test/typed.beEmptyTests.fs @@ -5,6 +5,7 @@ open FsUnitTyped [] type ``shouldBeEmpty tests``() = + [] member _.``empty List should be Empty``() = [] |> shouldBeEmpty diff --git a/tests/FsUnit.NUnit.Test/typed.haveLengthTests.fs b/tests/FsUnit.NUnit.Test/typed.haveLengthTests.fs index 766d25dd..6d0c9668 100644 --- a/tests/FsUnit.NUnit.Test/typed.haveLengthTests.fs +++ b/tests/FsUnit.NUnit.Test/typed.haveLengthTests.fs @@ -5,6 +5,7 @@ open FsUnitTyped [] type ``haveLength tests``() = + // F# List [] member _.``List with 1 item should have Length 1``() = diff --git a/tests/FsUnit.NUnit.Test/typed.shouldBeGreaterThanTests.fs b/tests/FsUnit.NUnit.Test/typed.shouldBeGreaterThanTests.fs index 93d77c95..765c0ef8 100644 --- a/tests/FsUnit.NUnit.Test/typed.shouldBeGreaterThanTests.fs +++ b/tests/FsUnit.NUnit.Test/typed.shouldBeGreaterThanTests.fs @@ -5,6 +5,7 @@ open FsUnitTyped [] type ``shouldBeGreaterThan tests``() = + [] member _.``11 should be greater than 10``() = 11 |> shouldBeGreaterThan 10 diff --git a/tests/FsUnit.NUnit.Test/typed.shouldBeSmallerThanTests.fs b/tests/FsUnit.NUnit.Test/typed.shouldBeSmallerThanTests.fs index ede11a7c..19332c15 100644 --- a/tests/FsUnit.NUnit.Test/typed.shouldBeSmallerThanTests.fs +++ b/tests/FsUnit.NUnit.Test/typed.shouldBeSmallerThanTests.fs @@ -5,6 +5,7 @@ open FsUnitTyped [] type ``shouldBeSmallerThan tests``() = + [] member _.``10 should be less than 11``() = 10 |> shouldBeSmallerThan 11 diff --git a/tests/FsUnit.NUnit.Test/typed.shouldContainTests.fs b/tests/FsUnit.NUnit.Test/typed.shouldContainTests.fs index d839155c..c9d6e60f 100644 --- a/tests/FsUnit.NUnit.Test/typed.shouldContainTests.fs +++ b/tests/FsUnit.NUnit.Test/typed.shouldContainTests.fs @@ -5,6 +5,7 @@ open FsUnitTyped [] type ``shouldContain tests``() = + [] member _.``List with item should contain item``() = [ 1 ] |> shouldContain 1 diff --git a/tests/FsUnit.NUnit.Test/typed.shouldContainText.fs b/tests/FsUnit.NUnit.Test/typed.shouldContainText.fs index ae2bc8fb..2ef8503f 100644 --- a/tests/FsUnit.NUnit.Test/typed.shouldContainText.fs +++ b/tests/FsUnit.NUnit.Test/typed.shouldContainText.fs @@ -5,6 +5,7 @@ open FsUnitTyped [] type ``shouldContainText tests``() = + [] member _.``empty string should contain ""``() = "" |> shouldContainText "" @@ -12,3 +13,7 @@ type ``shouldContainText tests``() = [] member _.``ships should contain hip``() = "ships" |> shouldContainText "hip" + + [] + member _.``ships should not contain lip``() = + "ships" |> shouldNotContainText "lip" diff --git a/tests/FsUnit.NUnit.Test/typed.shouldEqualNullTests.fs b/tests/FsUnit.NUnit.Test/typed.shouldEqualNullTests.fs deleted file mode 100644 index 5232fc6a..00000000 --- a/tests/FsUnit.NUnit.Test/typed.shouldEqualNullTests.fs +++ /dev/null @@ -1,14 +0,0 @@ -namespace FsUnit.Typed.Test - -open NUnit.Framework -open FsUnitTyped - -[] -type ``Typed: shouldEqual null tests``() = - [] - member _.``null should be null``() = - null |> shouldEqual null - - [] - member _.``null should fail to not be null``() = - shouldFail(fun () -> null |> shouldNotEqual null) diff --git a/tests/FsUnit.NUnit.Test/typed.shouldEqualTests.fs b/tests/FsUnit.NUnit.Test/typed.shouldEqualTests.fs index f0b2c012..3d45ae08 100644 --- a/tests/FsUnit.NUnit.Test/typed.shouldEqualTests.fs +++ b/tests/FsUnit.NUnit.Test/typed.shouldEqualTests.fs @@ -17,6 +17,7 @@ type NeverEqual() = [] type ``shouldEqual Tests``() = + let anObj = obj() let otherObj = obj() let anImmutableArray = ImmutableArray.Create(1, 2, 3) @@ -74,6 +75,14 @@ type ``shouldEqual Tests``() = member _.``should fail when negated and Equals returns true``() = shouldFail(fun () -> anObj |> shouldNotEqual(box(AlwaysEqual()))) + [] + member _.``null should be null``() = + null |> shouldEqual null + + [] + member _.``null should fail to not be null``() = + shouldFail(fun () -> null |> shouldNotEqual null) + [] member _.``None should equal None``() = None |> shouldEqual None diff --git a/tests/FsUnit.NUnit.Test/typed.shouldFailTests.fs b/tests/FsUnit.NUnit.Test/typed.shouldFailTests.fs index 13e0f34f..11e693f5 100644 --- a/tests/FsUnit.NUnit.Test/typed.shouldFailTests.fs +++ b/tests/FsUnit.NUnit.Test/typed.shouldFailTests.fs @@ -5,6 +5,7 @@ open FsUnitTyped [] type ``shouldFail tests``() = + [] member _.``empty List should fail to contain item``() = shouldFail(fun () -> [] |> shouldContain 1) diff --git a/tests/FsUnit.Xunit.Test/FsUnit.Xunit.Test.fsproj b/tests/FsUnit.Xunit.Test/FsUnit.Xunit.Test.fsproj index 56cbbc28..98dd7621 100644 --- a/tests/FsUnit.Xunit.Test/FsUnit.Xunit.Test.fsproj +++ b/tests/FsUnit.Xunit.Test/FsUnit.Xunit.Test.fsproj @@ -5,9 +5,6 @@ - - - @@ -17,33 +14,35 @@ + + + + + + - - - - + + + - - - - - + + + - - + diff --git a/tests/FsUnit.Xunit.Test/beAscendingTests.fs b/tests/FsUnit.Xunit.Test/beAscendingTests.fs index 7003bacf..1fe1f8a2 100644 --- a/tests/FsUnit.Xunit.Test/beAscendingTests.fs +++ b/tests/FsUnit.Xunit.Test/beAscendingTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be ascending tests``() = + [] member _.``Empty list should be ascending``() = [] |> should be ascending diff --git a/tests/FsUnit.Xunit.Test/beChoice.fs b/tests/FsUnit.Xunit.Test/beChoice.fs index e194f3e0..b6951577 100644 --- a/tests/FsUnit.Xunit.Test/beChoice.fs +++ b/tests/FsUnit.Xunit.Test/beChoice.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be choice tests``() = + [] member _.``Choice1Of2 should be the first choice``() = Choice.Choice1Of2(1) |> should be (choice 1) diff --git a/tests/FsUnit.Xunit.Test/beDescendingTests.fs b/tests/FsUnit.Xunit.Test/beDescendingTests.fs index 4d852738..7aabea9f 100644 --- a/tests/FsUnit.Xunit.Test/beDescendingTests.fs +++ b/tests/FsUnit.Xunit.Test/beDescendingTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be descending tests``() = + [] member _.``Empty list should be descending``() = [] |> should be descending diff --git a/tests/FsUnit.Xunit.Test/beEmptyStringTests.fs b/tests/FsUnit.Xunit.Test/beEmptyStringTests.fs index 63b5e64f..1ad9a77d 100644 --- a/tests/FsUnit.Xunit.Test/beEmptyStringTests.fs +++ b/tests/FsUnit.Xunit.Test/beEmptyStringTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be EmptyString tests``() = + [] member _.``empty string should be EmptyString``() = "" |> should be NullOrEmptyString diff --git a/tests/FsUnit.Xunit.Test/beEmptyTests.fs b/tests/FsUnit.Xunit.Test/beEmptyTests.fs index b6849984..5225347c 100644 --- a/tests/FsUnit.Xunit.Test/beEmptyTests.fs +++ b/tests/FsUnit.Xunit.Test/beEmptyTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be Empty tests``() = + [] member _.``empty List should be Empty``() = [] |> should be Empty diff --git a/tests/FsUnit.Xunit.Test/beFalseTests.fs b/tests/FsUnit.Xunit.Test/beFalseTests.fs index 26895718..04ea1937 100644 --- a/tests/FsUnit.Xunit.Test/beFalseTests.fs +++ b/tests/FsUnit.Xunit.Test/beFalseTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be False tests``() = + [] member _.``false should be False``() = false |> should be False diff --git a/tests/FsUnit.Xunit.Test/beGreaterThanOrEqualTo.fs b/tests/FsUnit.Xunit.Test/beGreaterThanOrEqualTo.fs index 547c15b7..16558bae 100644 --- a/tests/FsUnit.Xunit.Test/beGreaterThanOrEqualTo.fs +++ b/tests/FsUnit.Xunit.Test/beGreaterThanOrEqualTo.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be greaterThanOrEqualTo tests``() = + [] member _.``11 should be greater than 10``() = 11 |> should be (greaterThanOrEqualTo 10) diff --git a/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs b/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs index d0592c40..35e88ccb 100644 --- a/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs +++ b/tests/FsUnit.Xunit.Test/beGreaterThanTests.fs @@ -5,6 +5,7 @@ open FsUnit.Xunit open Xunit.Sdk type ``be greaterThan tests``() = + [] member _.``11 should be greater than 10``() = 11 |> should be (greaterThan 10) diff --git a/tests/FsUnit.Xunit.Test/beInRangeTests.fs b/tests/FsUnit.Xunit.Test/beInRangeTests.fs index 52e8ca07..0b73ed72 100644 --- a/tests/FsUnit.Xunit.Test/beInRangeTests.fs +++ b/tests/FsUnit.Xunit.Test/beInRangeTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be inRange tests``() = + [] member _.``25 should be in range from 5 to 30``() = 25 |> should be (inRange 5 30) diff --git a/tests/FsUnit.Xunit.Test/beLessThanOrEqualToTests.fs b/tests/FsUnit.Xunit.Test/beLessThanOrEqualToTests.fs index 9b795bb1..bd6b5ec8 100644 --- a/tests/FsUnit.Xunit.Test/beLessThanOrEqualToTests.fs +++ b/tests/FsUnit.Xunit.Test/beLessThanOrEqualToTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be lessThanOrEqualTo tests``() = + [] member _.``10 should be less than 11``() = 10 |> should be (lessThanOrEqualTo 11) diff --git a/tests/FsUnit.Xunit.Test/beLessThanTests.fs b/tests/FsUnit.Xunit.Test/beLessThanTests.fs index c36a197b..0b1a69d2 100644 --- a/tests/FsUnit.Xunit.Test/beLessThanTests.fs +++ b/tests/FsUnit.Xunit.Test/beLessThanTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be lessThan tests``() = + [] member _.``10 should be less than 11``() = 10 |> should be (lessThan 11) diff --git a/tests/FsUnit.Xunit.Test/NaNTests.fs b/tests/FsUnit.Xunit.Test/beNaNTests.fs similarity index 94% rename from tests/FsUnit.Xunit.Test/NaNTests.fs rename to tests/FsUnit.Xunit.Test/beNaNTests.fs index f58d52f0..9c1ef9e5 100644 --- a/tests/FsUnit.Xunit.Test/NaNTests.fs +++ b/tests/FsUnit.Xunit.Test/beNaNTests.fs @@ -4,7 +4,8 @@ open Xunit open FsUnit.Xunit open System -type ``Not a Number tests``() = +type ``be NaN tests``() = + [] member _.``Number 1 should be a number``() = 1 |> should not' (be NaN) diff --git a/tests/FsUnit.Xunit.Test/beNullOrEmptyStringTests.fs b/tests/FsUnit.Xunit.Test/beNullOrEmptyStringTests.fs index d1397613..5571e9c9 100644 --- a/tests/FsUnit.Xunit.Test/beNullOrEmptyStringTests.fs +++ b/tests/FsUnit.Xunit.Test/beNullOrEmptyStringTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be NullOrEmptyString tests``() = + [] member _.``empty string should be NullOrEmptyString``() = "" |> should be NullOrEmptyString diff --git a/tests/FsUnit.Xunit.Test/beNullTests.fs b/tests/FsUnit.Xunit.Test/beNullTests.fs index 1583ec7c..d7018cd8 100644 --- a/tests/FsUnit.Xunit.Test/beNullTests.fs +++ b/tests/FsUnit.Xunit.Test/beNullTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be Null tests``() = + [] member _.``null should be Null``() = null |> should be Null diff --git a/tests/FsUnit.Xunit.Test/ofCaseTests.fs b/tests/FsUnit.Xunit.Test/beOfCaseTests.fs similarity index 98% rename from tests/FsUnit.Xunit.Test/ofCaseTests.fs rename to tests/FsUnit.Xunit.Test/beOfCaseTests.fs index 6380e210..551b0ed2 100644 --- a/tests/FsUnit.Xunit.Test/ofCaseTests.fs +++ b/tests/FsUnit.Xunit.Test/beOfCaseTests.fs @@ -9,7 +9,8 @@ type TestUnion = | Second of int | Third of string -type ``ofCase tests``() = +type ``be ofCase tests``() = + [] let ``Given a (parameterless) union case of matching case returns true``() = First |> should be (ofCase <@ First @>) diff --git a/tests/FsUnit.Xunit.Test/beOfExactTypeTests.fs b/tests/FsUnit.Xunit.Test/beOfExactTypeTests.fs index 3229eb8c..8574bf1f 100644 --- a/tests/FsUnit.Xunit.Test/beOfExactTypeTests.fs +++ b/tests/FsUnit.Xunit.Test/beOfExactTypeTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``should be of exact type tests``() = +type ``be ofExactType tests``() = + [] member _.``empty string should be of exact type String``() = "" |> should be ofExactType diff --git a/tests/FsUnit.Xunit.Test/beSameAsTests.fs b/tests/FsUnit.Xunit.Test/beSameAsTests.fs index e63e3ebd..95397ad4 100644 --- a/tests/FsUnit.Xunit.Test/beSameAsTests.fs +++ b/tests/FsUnit.Xunit.Test/beSameAsTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``be SameAs tests``() = +type ``be sameAs tests``() = + let anObj = obj() let otherObj = obj() diff --git a/tests/FsUnit.Xunit.Test/beTrueTests.fs b/tests/FsUnit.Xunit.Test/beTrueTests.fs index 35ef546e..db892337 100644 --- a/tests/FsUnit.Xunit.Test/beTrueTests.fs +++ b/tests/FsUnit.Xunit.Test/beTrueTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``be True tests``() = + [] member _.``true should be True``() = true |> should be True diff --git a/tests/FsUnit.Xunit.Test/beUniqueTests.fs b/tests/FsUnit.Xunit.Test/beUniqueTests.fs index 58535a35..c6591c77 100644 --- a/tests/FsUnit.Xunit.Test/beUniqueTests.fs +++ b/tests/FsUnit.Xunit.Test/beUniqueTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``have unique items list tests``() = +type ``be unique tests``() = + [] member _.``empty list should be considered as unique``() = [] |> should be unique diff --git a/tests/FsUnit.Xunit.Test/containTests.fs b/tests/FsUnit.Xunit.Test/containTests.fs index b7120b24..b29fda9e 100644 --- a/tests/FsUnit.Xunit.Test/containTests.fs +++ b/tests/FsUnit.Xunit.Test/containTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnit.Xunit type ``contain tests``() = + [] member _.``List with item should contain item``() = [ 1 ] |> should contain 1 diff --git a/tests/FsUnit.Xunit.Test/shouldEndWithTests.fs b/tests/FsUnit.Xunit.Test/endWithTests.fs similarity index 91% rename from tests/FsUnit.Xunit.Test/shouldEndWithTests.fs rename to tests/FsUnit.Xunit.Test/endWithTests.fs index 1c2670c9..3460fdb6 100644 --- a/tests/FsUnit.Xunit.Test/shouldEndWithTests.fs +++ b/tests/FsUnit.Xunit.Test/endWithTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``should endWith tests``() = +type ``endWith tests``() = + [] member _.``empty string should end with ""``() = "" |> should endWith "" diff --git a/tests/FsUnit.Xunit.Test/equalSeqTests.fs b/tests/FsUnit.Xunit.Test/equalSeqTests.fs index 9b134027..45f0d45f 100644 --- a/tests/FsUnit.Xunit.Test/equalSeqTests.fs +++ b/tests/FsUnit.Xunit.Test/equalSeqTests.fs @@ -3,7 +3,7 @@ open Xunit open FsUnit.Xunit -type ``equalSeq Tests``() = +type ``equalSeq tests``() = [] member _.``sequence should equal sequence``() = diff --git a/tests/FsUnit.Xunit.Test/equalTests.fs b/tests/FsUnit.Xunit.Test/equalTests.fs index da001746..5c4247a4 100644 --- a/tests/FsUnit.Xunit.Test/equalTests.fs +++ b/tests/FsUnit.Xunit.Test/equalTests.fs @@ -15,7 +15,8 @@ type NeverEqual() = override this.Equals(other) = false override this.GetHashCode() = 1 -type ``equal Tests``() = +type ``equal tests``() = + let anObj = obj() let otherObj = obj() let anImmutableArray = ImmutableArray.Create(1, 2, 3) @@ -98,6 +99,10 @@ type ``equal Tests``() = member _.``None should equal None``() = None |> should equal None + [] + member _.``None should equal null``() = + None |> should equal null + [] member _.``structural value type should equal equivalent value``() = anImmutableArray |> should equal equivalentImmutableArray diff --git a/tests/FsUnit.Xunit.Test/equalWithinTests.fs b/tests/FsUnit.Xunit.Test/equalWithinTests.fs index e4f64501..5588b1ad 100644 --- a/tests/FsUnit.Xunit.Test/equalWithinTests.fs +++ b/tests/FsUnit.Xunit.Test/equalWithinTests.fs @@ -3,9 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -(* Thanks to erdoll for this suggestion: https://fsunit.codeplex.com/discussions/269320 *) - type ``equalWithin tests``() = + [] member _.``should equal within tolerance``() = 10.1 |> should (equalWithin 0.1) 10.11 diff --git a/tests/FsUnit.Xunit.Test/haveCountTests.fs b/tests/FsUnit.Xunit.Test/haveCountTests.fs index 52fae7cb..d4d10f52 100644 --- a/tests/FsUnit.Xunit.Test/haveCountTests.fs +++ b/tests/FsUnit.Xunit.Test/haveCountTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``have Count tests``() = +type ``haveCount tests``() = + let emptyList = System.Collections.Generic.List() let singleItemList = System.Collections.Generic.List() diff --git a/tests/FsUnit.Xunit.Test/haveLengthTests.fs b/tests/FsUnit.Xunit.Test/haveLengthTests.fs index ae1b5b67..c00d4b0a 100644 --- a/tests/FsUnit.Xunit.Test/haveLengthTests.fs +++ b/tests/FsUnit.Xunit.Test/haveLengthTests.fs @@ -5,6 +5,7 @@ open Xunit.Sdk open FsUnit.Xunit type ``haveLength tests``() = + // F# List [] member _.``List with 1 item should have Length 1``() = diff --git a/tests/FsUnit.Xunit.Test/shouldHaveSubstringTests.fs b/tests/FsUnit.Xunit.Test/haveSubstringTests.fs similarity index 90% rename from tests/FsUnit.Xunit.Test/shouldHaveSubstringTests.fs rename to tests/FsUnit.Xunit.Test/haveSubstringTests.fs index 2c2f5b2b..65dff1a6 100644 --- a/tests/FsUnit.Xunit.Test/shouldHaveSubstringTests.fs +++ b/tests/FsUnit.Xunit.Test/haveSubstringTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``should haveSubstring tests``() = +type ``haveSubstring tests``() = + [] member _.``empty string should contain ""``() = "" |> should haveSubstring "" diff --git a/tests/FsUnit.Xunit.Test/instanceOfTests.fs b/tests/FsUnit.Xunit.Test/instanceOfTypeTests.fs similarity index 95% rename from tests/FsUnit.Xunit.Test/instanceOfTests.fs rename to tests/FsUnit.Xunit.Test/instanceOfTypeTests.fs index 975b7dba..7f85c60d 100644 --- a/tests/FsUnit.Xunit.Test/instanceOfTests.fs +++ b/tests/FsUnit.Xunit.Test/instanceOfTypeTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``Instance Of tests``() = +type ``instanceOfType tests``() = + [] member _.``int should be instance of type Object``() = 1 |> should be instanceOfType diff --git a/tests/FsUnit.Xunit.Test/matchListTests.fs b/tests/FsUnit.Xunit.Test/matchListTests.fs index 70cda850..d93ae9d9 100755 --- a/tests/FsUnit.Xunit.Test/matchListTests.fs +++ b/tests/FsUnit.Xunit.Test/matchListTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Test open Xunit open FsUnit.Xunit -type ``match List tests``() = +type ``matchList tests``() = + [] member _.``Empty list should match itself``() = ([]: List) |> should matchList ([]: List) diff --git a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs b/tests/FsUnit.Xunit.Test/startWithTests.fs similarity index 94% rename from tests/FsUnit.Xunit.Test/shouldStartWithTests.fs rename to tests/FsUnit.Xunit.Test/startWithTests.fs index fea87085..803415a3 100644 --- a/tests/FsUnit.Xunit.Test/shouldStartWithTests.fs +++ b/tests/FsUnit.Xunit.Test/startWithTests.fs @@ -5,7 +5,8 @@ open Xunit.Sdk open FsUnit.Xunit open FsUnitTyped -type ``should startWith tests``() = +type ``startWith tests``() = + [] member _.``empty string should start with ""``() = "" |> should startWith "" diff --git a/tests/FsUnit.Xunit.Test/typed.beEmptyTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldBeEmptyTests.fs similarity index 99% rename from tests/FsUnit.Xunit.Test/typed.beEmptyTests.fs rename to tests/FsUnit.Xunit.Test/typed.shouldBeEmptyTests.fs index 43d8c642..284800b6 100644 --- a/tests/FsUnit.Xunit.Test/typed.beEmptyTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldBeEmptyTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnitTyped type ``shouldBeEmpty tests``() = + [] member _.``empty List should be Empty``() = [] |> shouldBeEmpty diff --git a/tests/FsUnit.Xunit.Test/typed.shouldBeGreaterThanTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldBeGreaterThanTests.fs index 71cc3309..9b728c54 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldBeGreaterThanTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldBeGreaterThanTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnitTyped type ``shouldBeGreaterThan tests``() = + [] member _.``11 should be greater than 10``() = 11 |> shouldBeGreaterThan 10 diff --git a/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs index 7900ce98..c020edc0 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldBeSmallerThanTests.fs @@ -6,6 +6,7 @@ open Xunit.Sdk open FsUnitTyped type ``shouldBeSmallerThan tests``() = + [] member _.``10 should be less than 11``() = 10 |> shouldBeSmallerThan 11 diff --git a/tests/FsUnit.Xunit.Test/typed.shouldContainTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldContainTests.fs index 00e3d72f..f6b51448 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldContainTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldContainTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnitTyped type ``shouldContain tests``() = + [] member _.``List with item should contain item``() = [ 1 ] |> shouldContain 1 diff --git a/tests/FsUnit.Xunit.Test/typed.shouldContainText.fs b/tests/FsUnit.Xunit.Test/typed.shouldContainTextTests.fs similarity index 72% rename from tests/FsUnit.Xunit.Test/typed.shouldContainText.fs rename to tests/FsUnit.Xunit.Test/typed.shouldContainTextTests.fs index 1ed714b2..eb8bf90f 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldContainText.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldContainTextTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnitTyped type ``shouldContainText tests``() = + [] member _.``empty string should contain ""``() = "" |> shouldContainText "" @@ -11,3 +12,7 @@ type ``shouldContainText tests``() = [] member _.``ships should contain hip``() = "ships" |> shouldContainText "hip" + + [] + member _.``ships should not contain lip``() = + "ships" |> shouldNotContainText "lip" diff --git a/tests/FsUnit.Xunit.Test/typed.shouldEqualNullTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldEqualNullTests.fs deleted file mode 100644 index 8040d93d..00000000 --- a/tests/FsUnit.Xunit.Test/typed.shouldEqualNullTests.fs +++ /dev/null @@ -1,13 +0,0 @@ -namespace FsUnit.Typed.Test - -open Xunit -open FsUnitTyped - -type ``Typed: shouldEqual null tests``() = - [] - member _.``null should be null``() = - null |> shouldEqual null - - [] - member _.``null should fail to not be null``() = - shouldFail(fun () -> null |> shouldNotEqual null) diff --git a/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs index 8efcbff5..6f7a4261 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldEqualTests.fs @@ -2,7 +2,6 @@ namespace FsUnit.Typed.Test open System.Collections.Immutable -open FsUnit.Xunit open Xunit open Xunit.Sdk open FsUnitTyped @@ -17,6 +16,7 @@ type NeverEqual() = override _.GetHashCode() = 1 type ``shouldEqual Tests``() = + let anObj = obj() let otherObj = obj() let anImmutableArray = ImmutableArray.Create(1, 2, 3) @@ -71,6 +71,14 @@ type ``shouldEqual Tests``() = member _.``should fail when negated and Equals returns true``() = shouldFail(fun () -> anObj |> shouldNotEqual(box(AlwaysEqual()))) + [] + member _.``null should be null``() = + null |> shouldEqual null + + [] + member _.``null should fail to not be null``() = + shouldFail(fun () -> null |> shouldNotEqual null) + [] member _.``None should equal None``() = None |> shouldEqual None @@ -85,12 +93,8 @@ type ``shouldEqual Tests``() = |> Assert.Throws |> fun e -> e.Message - |> shouldEqual( - sprintf - "Assert.Equal() Failure: Values differ%sExpected: Equals Error \"Bar\"%sActual: Error \"Foo\"" - Environment.NewLine - Environment.NewLine - ) + |> shouldEqual + $"Assert.Equal() Failure: Values differ%s{Environment.NewLine}Expected: Equals Error \"Bar\"%s{Environment.NewLine}Actual: Error \"Foo\"" [] member _.``Error "Foo" should not equal Error "Bar"``() = @@ -102,12 +106,8 @@ type ``shouldEqual Tests``() = |> Assert.Throws |> fun e -> e.Message - |> shouldEqual( - sprintf - "Assert.Equal() Failure: Values differ%sExpected: not Equals Error \"Foo\"%sActual: Error \"Foo\"" - Environment.NewLine - Environment.NewLine - ) + |> shouldEqual + $"Assert.Equal() Failure: Values differ%s{Environment.NewLine}Expected: not Equals Error \"Foo\"%s{Environment.NewLine}Actual: Error \"Foo\"" [] member this.``structural equality``() = diff --git a/tests/FsUnit.Xunit.Test/typed.shouldFailTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldFailTests.fs index 85e1f7ed..334d3628 100644 --- a/tests/FsUnit.Xunit.Test/typed.shouldFailTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldFailTests.fs @@ -4,6 +4,7 @@ open Xunit open FsUnitTyped type ``shouldFail tests``() = + [] member _.``empty List should fail to contain item``() = shouldFail(fun () -> [] |> shouldContain 1) diff --git a/tests/FsUnit.Xunit.Test/typed.haveLengthTests.fs b/tests/FsUnit.Xunit.Test/typed.shouldHaveLengthTests.fs similarity index 93% rename from tests/FsUnit.Xunit.Test/typed.haveLengthTests.fs rename to tests/FsUnit.Xunit.Test/typed.shouldHaveLengthTests.fs index 94e3b375..634b1395 100644 --- a/tests/FsUnit.Xunit.Test/typed.haveLengthTests.fs +++ b/tests/FsUnit.Xunit.Test/typed.shouldHaveLengthTests.fs @@ -3,7 +3,8 @@ namespace FsUnit.Typed.Test open Xunit open FsUnitTyped -type ``haveLength tests``() = +type ``shouldHaveLength tests``() = + // F# List [] member _.``List with 1 item should have Length 1``() =