protected void AssertThatExceptionParamNameShouldMatchCustomArgumentName <TException>(TestDelegate assertThat, string customArgumentName) where TException : ArgumentException { assertThat.ThrowIfNull(nameof(assertThat)); var exception = Assert.Throws <TException>(assertThat, TestBaseStringResources.ExpectedExceptionOfTypeXBecauseInvalidInput(typeof(TException))); Assert.AreEqual(customArgumentName, exception.ParamName, TestBaseStringResources.ExpectedInputParameterNameToMatchExceptionParameterName()); }
protected void AssertThatExceptionParamNameAndMessageShouldMatch <TException>(TestDelegate assertThat, [CanBeNull] string customArgumentName, string expectedMessage) where TException : ArgumentException { assertThat.ThrowIfNull(nameof(assertThat)); expectedMessage.ThrowIfNull(nameof(expectedMessage)); var exception = Assert.Throws <TException>(assertThat, TestBaseStringResources.ExpectedExceptionOfTypeXBecauseInvalidInput(typeof(TException))); Assert.AreEqual(customArgumentName, exception.ParamName, TestBaseStringResources.ExpectedInputParameterNameToMatchExceptionParameterName()); Assert.That(exception.Message.Contains(expectedMessage, StringComparison.InvariantCultureIgnoreCase), TestBaseStringResources.ExpectedMessageToMatchExceptionMessage()); }
protected void AssertThatExceptionParamNameAndMessageShouldMatchDefaultArgumentName <TException>(TestDelegate assertThat, string defaultMessage) where TException : ArgumentException { assertThat.ThrowIfNull(nameof(assertThat)); defaultMessage.ThrowIfNull(nameof(defaultMessage)); var exception = Assert.Throws <TException>(assertThat, TestBaseStringResources.ExpectedExceptionOfTypeXBecauseInvalidInput(typeof(TException))); Assert.IsTrue(exception.Message.Contains(defaultMessage, StringComparison.CurrentCulture), TestBaseStringResources.ExpectedMessageToMatchExceptionMessage()); Assert.AreEqual(DefaultArgumentName, exception.ParamName, TestBaseStringResources.ExpectedInputParameterNameToMatchExceptionParameterName()); }