public void InvalidStateChangeExceptionPassesCorrectInnerExceptionWhenThrown() { // Try to throw InvalidStateChangeException with an inner exception and check if the inner exception // returned after throwing is same as the one passed when throwing and that it returns the correct message var innerEx = new Exception(); var ex = new InvalidStateChangeException("Testing Exception", innerEx); if (ex.InnerException != null) { Assert.AreEqual(innerEx, ex.InnerException, "Exception returned unexpected inner exception"); Assert.AreEqual("Testing Exception", ex.Message, "Exception returned unexpected message"); } else { Assert.Fail("Inner Exception was not passed when throwing exception"); } }
public void InvalidStateChangeExceptionWithMessageReturnsCorrectMessage() { var ex = new InvalidStateChangeException("Testing Exception"); Assert.AreEqual("Testing Exception", ex.Message); }