Shouldly
Search…
Flags
ShouldHaveFlag allows you to assert whether an object is an enum and has a flag specified.
Conversely ShouldNotHaveFlag allows you to assert the opposite; that an object is an enum but does not have a flag specified.

ShouldHaveFlag

1
var actual = TestEnum.FlagTwo;
2
var value = TestEnum.FlagOne;
3
actual.ShouldHaveFlag(value);
Copied!
Exception
1
actual
2
should have flag
3
TestEnum.FlagOne
4
but had
5
TestEnum.FlagTwo
Copied!

ShouldNotHaveFlag

1
var actual = TestEnum.FlagOne;
2
var value = TestEnum.FlagOne;
3
actual.ShouldNotHaveFlag(value);
Copied!
Exception
1
actual
2
should not have flag
3
TestEnum.FlagOne
4
but it had
5
TestEnum.FlagOne
Copied!
Last modified 1yr ago