diff --git a/docs/content/assertions.fsx b/docs/content/assertions.fsx index 149d78d4..f14ef93e 100644 --- a/docs/content/assertions.fsx +++ b/docs/content/assertions.fsx @@ -57,6 +57,13 @@ Assert that one string contains another. *) contains "Log" (read "#logout") +(** +containsInsensitive +-------- +Assert that one string contains (case insensitive) another. +*) +containsInsensitive "Log" (read "#logout") + (** notContains -------- diff --git a/src/canopy/canopy.fs b/src/canopy/canopy.fs index e973de58..129dfcdf 100644 --- a/src/canopy/canopy.fs +++ b/src/canopy/canopy.fs @@ -550,6 +550,13 @@ let contains (value1 : string) (value2 : string) = if (value2.Contains(value1) <> true) then raise (CanopyContainsFailedException(sprintf "contains check failed. %s does not contain %s" value2 value1)) +(* documented/assertions *) +let containsInsensitive (value1 : string) (value2 : string) = + let rules = StringComparison.InvariantCultureIgnoreCase + let contains = value2.IndexOf(value1, rules) + if contains < 0 then + raise (CanopyContainsFailedException(sprintf "contains insensitive check failed. %s does not contain %s" value2 value1)) + (* documented/assertions *) let notContains (value1 : string) (value2 : string) = if (value2.Contains(value1) = true) then