简体   繁体   English

如何使用 FsUnit.Xunit 测试“不应包含”?

[英]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 .我正在尝试使用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' .我也尝试过使用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. contains 是一个contain ,它需要一个值并返回一个约束。

 xs |> should not' (contain 99) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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