Shouldly
Search
K

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

var actual = TestEnum.FlagTwo;
var value = TestEnum.FlagOne;
actual.ShouldHaveFlag(value);
Exception
actual
should have flag
TestEnum.FlagOne
but had
TestEnum.FlagTwo

ShouldNotHaveFlag

var actual = TestEnum.FlagOne;
var value = TestEnum.FlagOne;
actual.ShouldNotHaveFlag(value);
Exception
actual
should not have flag
TestEnum.FlagOne
but it had
TestEnum.FlagOne
Last modified 5mo ago