简体   繁体   中英

How do I test “should not contain” using FsUnit.Xunit?

I am trying to test that a collection does not contain a value using FsUnit.Xunit .

open FsUnit.Xunit

[<Fact>]
let ``simple test`` () =
  let xs = [ 1; 2; 3 ]

  xs |> should contain 1

  xs |> should not contain 99 // Not real code

I have also tried using not' .

How should I write this?

You just need to wrap it in parenthesis since it expects a constraint (and not a function). contain is a function that expects a value and returns a constraint.

 xs |> should not' (contain 99) 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM