public void TriState_ToStringWithInvalidStyle_ThrowsArgumentOutOfRangeException() { TriState testTriState = (Random.Next() % 3 - 1); const TriState.Style testStyle = (TriState.Style) 4; // note: this test assumes there is no style with value 4 Assert.AreEqual( "4", testStyle.ToString(), "For this test to correctly function, the style used should be invalid. When this holds, the string representation of the style is a number."); testTriState.ToString(testStyle); }
public void TriState_IFormattableWithValidStyle_GivesSameResultAsToString() { Random randSource = new Random(); TriState testTriState = (Random.Next() % 3 - 1); TriState.Style testStyle = (new List <TriState.Style> { TriState.Style.YesUnknownNo, TriState.Style.NegativeEqualPositive, TriState.Style.TrueUndefinedFalse }).OrderBy(x => randSource.Next()).First(); Assert.AreEqual( testTriState.ToString(testStyle), testTriState.ToString(testStyle.ToString(), null), "The result of IFormattable.ToString with the string representation of a style as the format should be the same as ToString with that same style."); }