I am trying to test my collection using :
var costByFactoryt = dataAccess.GetcostPerFactoryt(null, null);
costByFactoryt.Count().Should().BeGreaterThan(0);
costByFactoryt.Select(x => x.Cost.Should().BeGreaterThan(100));
But the problem is , if I change the last line of code to,
costByFactoryt.Select(x => x.Cost.Should().BeGreaterThan(1000));
or
costingByCircuit.Select(x => x.Cost.Should().BeLessThan(100));
It still pass , which is wrong.
What I am trying to test is , all cost should be greater than 100.
It simply doesn't work that way because LINQ Select doesn't iterate the collection => your test code is not executed
According to Fluent Assertions documentation
The correct syntax should be
costingByCircuit.Select(x => x.Cost).Should().OnlyContain(x => x > 100);