public void Or_PassShowAllSpec_NoItemsAreFiltered() { // Arrange var first = new ExpressionSpec <ItemForTest>(x => true); var second = new ExpressionSpec <ItemForTest>(x => x.Id.Contains("2")); var items = new[] { new ItemForTest("11"), new ItemForTest("22"), new ItemForTest("33"), }; var orSpec = first.Or(second); // Act var result = items.Where(x => orSpec.IsSatisfy(x)).ToArray(); // Assert result.Should() .Contain(x => x.Id == "22") .And.HaveCount(1); }
public void Or_WhenMultipleSpecificationsAreApplicable_ShouldCorrectlyFilterItems() { // Arrange var first = new ExpressionSpec <ItemForTest>(x => x.Id.Contains("1")); var second = new ExpressionSpec <ItemForTest>(x => x.Id.Contains("2")); var items = new[] { new ItemForTest("11"), new ItemForTest("22"), new ItemForTest("33"), }; var orSpec = first.Or(second); // Act var result = items.Where(x => orSpec.IsSatisfy(x)).ToArray(); // Assert result .Should() .NotContain(x => x.Id == "33") .And .HaveCount(2); }