public void CannotBeGreaterThanFail(IComparable value, IComparable maxValue) { try { value.CannotBeGreaterThan(maxValue); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("Value cannot be null.", ex.Message); } catch (ArgumentException ex) { Assert.AreEqual($"Value cannot be greater than {maxValue}.", ex.Message); } try { value.CannotBeGreaterThan(maxValue, () => throw new InvalidOperationException("Test.")); Assert.Fail(); } catch (ArgumentNullException ex) { Assert.AreEqual("Value cannot be null.", ex.Message); } catch (InvalidOperationException ex) { Assert.AreEqual("Test.", ex.Message); } }
public void CannotBeGreaterThan(IComparable value, IComparable max) { Assert.AreSame(value, value.CannotBeGreaterThan(max)); }