---
agentTools:
  projectIndex: https://specsfor.readme.io/llms.txt
---

# Fuzzy Checks with Some and Any Values

[block:callout]
{
  "type": "info",
  "title": "NOTE",
  "body": "The techniques shown here only work with lambda-based partial matching.  They do not work with anonymous objects."
}
[/block]

The ShouldLookLike assertion also allows you to do fuzzy matching.  For example, you can check to make sure that a property isn't null:

[block:code]
{
  "codes": [
    {
      "code": "            [Test]\n            public void then_you_can_check_for_non_null_values()\n            {\n                var engine = new Engine { Maker = \"Heroic\" };\n                engine.ShouldLookLike(() => new Engine\n                {\n                    Maker = Any.NonNullValueOf<string>()\n                });\n            }",
      "language": "csharp"
    }
  ]
}
[/block]

You can also check for a specific value in a range:

[block:code]
{
  "codes": [
    {
      "code": "            [Test]\n            public void then_you_can_check_for_values_in_a_range()\n            {\n                var engine = new Engine {YearBuilt = 2015};\n                engine.ShouldLookLike(() => new Engine\n                {\n                    YearBuilt = Some.ValueInRange(2014, 2016)\n                });\n            }",
      "language": "csharp"
    }
  ]
}
[/block]

Or for a value matching some arbitrary criteria:

[block:code]
{
  "codes": [
    {
      "code": "            [Test]\n            public void then_you_can_check_for_a_value_matching_some_expression()\n            {\n                var engine = new Engine {Maker = \"Heroic\"};\n                engine.ShouldLookLike(() => new Engine\n                {\n                    Maker = Some.ValueOf<string>(s => char.IsUpper(s[0]))\n                });\n            }",
      "language": "csharp"
    }
  ]
}
[/block]

You can also check to make sure a list contains some value (or even a *partial* value!)

[block:code]
{
  "codes": [
    {
      "code": "            [Test]\n            public void then_you_can_check_for_an_item_in_a_list()\n            {\n                var warehouse = new Warehouse\n                {\n                    Engines = new[] {new Engine {YearBuilt = 2013}, new Engine {YearBuilt = 2016}}\n                };\n\n                warehouse.ShouldLookLike(() => new Warehouse\n                {\n                    Engines = Some.ListContaining(() => new Engine\n                    {\n                        //Yep, you can use partial matching recursively!\n                        YearBuilt = Some.ValueOf<int>(i => i % 2 == 0)\n                    })\n                });\n            }",
      "language": "csharp"
    }
  ]
}
[/block]