-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Hi, I am trying to test class constraints with ArchUnit and noticed that BeSealed() always seem to return a positive test, regardless of the actual class configuration.
This testcase should never be green, but is:
var commandsWithoutResult = Classes().That().ImplementAnyInterfaces(_commandInterfaceWithoutResult);
var commandsSealedRule = commandsWithoutResult.Should().BeSealed();
var commandsNotSealedRule = commandsWithoutResult.Should().NotBeSealed();
var rules = commandsSealedRule
.And(commandsNotSealedRule);
rulesCheck(Setup.Architecture);
I have a class matching the condition of commandsWithoutResult, and when I get the object via GetObjects and check for IsSealed manually, the Test correctly states, that my class is not sealed:
var objects = commandsWithoutResult.GetObjects(Setup.Architecture).ToArray();
objects.Should().AllSatisfy(o => o.IsSealed.Should().BeTrue());
In my Debugger, I see the IsSealed Property is set to false
Looking at the Sourcecode of BeSealed, I wonder whether the test just checks if the nullable value bool? IsSealed is set or not.
public static ICondition<Class> BeSealed()
{
return new SimpleCondition<Class>(
cls => !cls.IsSealed.HasValue || cls.IsSealed.Value,
"be sealed",
"is not sealed"
);
}
I feel like it should be !cls.IsSealed.HasValue && cls.IsSealed.Value == false. On the other hand, the definition of BeRecord() is the same and the BeRecord()-Test does not show this behaviour. So I am not exactly shure what is going on here.
Some willing to look into this?