確保值為 true 或 false

要宣告值為 true 或 false,請:

Assert.IsFalse(Settings.DoBadThings, "Bad things should not happen, disable DoBadThings.");
Assert.IsTrue(magicNumber =< 42, "The magic number is greater than 42!");

你還可以傳遞異常訊息的格式引數

Assert.IsFalse(myValue > 5, "The value should not be greater than 5, it's currently {0}", myValue);