Here are the examples of the csharp api NUnit.Framework.Assert.Throws(NUnit.Framework.TestDelegate) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
2067 Examples
19
Source : BoolToColorConverterTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void ConvertBack_ShouldThrowNotSupported()
{
replacedert.Throws<NotSupportedException>(() => mSut.ConvertBack(null, null, null, null));
}
19
Source : ChildTypeToVisibilityConverterTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void ConvertBack_ShouldThrowNotSupportedException()
{
replacedert.Throws<NotSupportedException>(() => mSut.ConvertBack(null, null, null, null));
}
19
Source : AddSaveStrategyTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenModelIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new AddSaveStrategy<ModelBase>(null, model => { }, new XmlDoreplacedent().CreateElement("element")));
}
19
Source : AddSaveStrategyTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenAddCallbackIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new AddSaveStrategy<ModelBase>(new RendererModel(null), null, new XmlDoreplacedent().CreateElement("element")));
}
19
Source : AddSaveStrategyTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenNewElementIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new AddSaveStrategy<ModelBase>(new RendererModel(null), model => { }, null));
}
19
Source : AppendReplaceSaveStrategyTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenConfigurationIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new AppendReplaceSaveStrategy(null, false));
}
19
Source : WindowSizeLocationFactoryTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Create_ShouldThrow_ForUnknownDescriptor()
{
replacedert.Throws<ArgumentException>(() => WindowSizeLocationFactory.Create(LayoutDescriptor.Simple));
}
19
Source : WindowSizeLocationFactoryTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Create_ShouldThrow_ForDenyAll()
{
replacedert.Throws<InvalidEnumArgumentException>(() => WindowSizeLocationFactory.Create(FilterDescriptor.DenyAll));
}
19
Source : BooleanPropertyBaseTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrowIfElementNameIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new BooleanPropertyBase("name", null, true));
}
19
Source : BooleanPropertyBaseTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrowIfNameIsNull()
{
replacedert.Throws<ArgumentNullException>(() => new BooleanPropertyBase(null, "elementName", true));
}
19
Source : DefinitionFactoryTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Create_ShouldThrow_WhenUnknownDescriptor()
{
replacedert.Throws<ArgumentException>(() => DefinitionFactory.Create(LayoutDescriptor.Simple, Subsreplacedute.For<IElementConfiguration>()));
}
19
Source : DefinitionFactoryTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Create_ShouldThrow_WhenDenyAll()
{
replacedert.Throws<InvalidEnumArgumentException>(() => DefinitionFactory.Create(FilterDescriptor.DenyAll, Subsreplacedute.For<IElementConfiguration>()));
}
19
Source : ConfigurationXmlTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenMessageBoxServiceIsNull()
{
// ReSharper disable once ObjectCreationreplacedtatement
replacedert.Throws<ArgumentNullException>(() => new ConfigurationXml(null, Subsreplacedute.For<ICanLoadAndSaveXml>()));
}
19
Source : ConfigurationXmlTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenLoadSaveIsNull()
{
// ReSharper disable once ObjectCreationreplacedtatement
replacedert.Throws<ArgumentNullException>(() => new ConfigurationXml(mToastService, null));
}
19
Source : ConfigurationXmlTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Reload_ShouldThrow_WhenNotLoadedFirst()
{
replacedert.Throws<InvalidOperationException>(() => mSut.Reload());
}
19
Source : AppenderModelTest.cs
with MIT License
from alexleen
with MIT License
from alexleen
[Test]
public void Ctor_ShouldThrow_WhenNodeNameDoesNotMatchDescriptorElementName()
{
XmlDoreplacedent xmlDoc = new XmlDoreplacedent();
xmlDoc.LoadXml("<log4net>" +
"<whatev>" +
"</whatev>" +
"</log4net>");
replacedert.Throws<ArgumentException>(() => new AppenderModel(AppenderDescriptor.Async, xmlDoc.FirstChild.FirstChild, 0));
}
19
Source : RSAEncryptorTest.cs
with Apache License 2.0
from alipay
with Apache License 2.0
from alipay
[Test()]
public void should_get_exception_when_content_to_be_sign_is_null()
{
//given
string content = null;
//then
AopException ex = replacedert.Throws<AopException>(() => Encryptor.Sign(content, "UTF-8", RSA_PrivateKey));
replacedert.AreEqual(ex.Message.Contains("待签名内容不可为Null"), true);
}
19
Source : RSAEncryptorTest.cs
with Apache License 2.0
from alipay
with Apache License 2.0
from alipay
[Test()]
public void should_get_exception_when_private_key_is_invalid()
{
//given
string content = "test";
string privateKey = @"BLSi7EW+cBAfuuepOfANrWGt5jSwSkD+6nf6PsWH2R07ZwRFDD3S3G9RiYS0aR9tgY1nggfTP0lz2uiVgAYO4A8=";
//then
AopException ex = replacedert.Throws<AopException>(() => Encryptor.Sign(content, "UTF-8", privateKey));
replacedert.AreEqual(ex.Message.Contains("签名遭遇异常,请检查私钥格式是否正确"), true);
}
19
Source : AlipaySignatureTest.cs
with Apache License 2.0
from alipay
with Apache License 2.0
from alipay
[Test]
public void should_get_exception_when_sign_not_match()
{
Dictionary<String, String> paramters = new Dictionary<string, string>
{
{ "biz_content", "test" },
{ "charset", "UTF-8" },
{ "sign", "DFM24dXl9tfymSvZvmwcjutWWDoCwF2b/6CqUY2ZdShmnucUGxKqpmDF0m4lu5cm2AKx2KxvrfyOHrpZUBhX9i3YKqj0CV1jDjWBdcFI2gGnNQeShdqGGDhuHgtVeQE8cH/Q7LWSfrJ3EZqKyvCXsAX2GQ7SuhTPbIrq8mlflcIQHIUxUfoucc2F/vBdumwYQ3bT+2P4+7z89AFrPIDQ5A4dh1l3dkHbMTaJrFAz5bSvo5gqNyVV/TLts28HeHvAAYDfGP4eWm5knnh/3AulLdOkj0+m8L/YUR9tUMvNMSB6IJFF7keKq4s6qovfXPJYGZUNfuWKp9EJwDALGD53zg=="}
};
AopException ex = replacedert.Throws<AopException>(() => AlipaySignature.CheckSignAndDecrypt(
paramters, TestAccount.Sandbox.GetConfig().AlipayPublicKey, TestAccount.Sandbox.GetConfig().PrivateKey, true, true, "RSA", false));
replacedert.AreEqual(ex.Message.Contains("rsaCheck failure"), true);
}
19
Source : CertificateExecuteTest.cs
with Apache License 2.0
from alipay
with Apache License 2.0
from alipay
[Test]
public void should_get_exeception_when_call_normal_execuet()
{
//given
IAopClient client = new DefaultAopClient(TestAccount.ProdCert.GetConfig());
AlipayOpenOperationOpenbizmockBizQueryRequest request = GetRequest();
//then
AopException ex = replacedert.Throws<AopException>(() => client.Execute(request));
replacedert.AreEqual(ex.Message.Contains("检测到证书相关参数已初始化,证书模式下请改为调用CertificateExecute。"), true);
}
19
Source : ExecuteTest.cs
with Apache License 2.0
from alipay
with Apache License 2.0
from alipay
[Test]
public void should_get_exception_when_call_cert_execute()
{
//given
IAopClient client = new DefaultAopClient(TestAccount.Sandbox.GetConfig());
AlipayTradeCreateRequest request = getTradeCreateRequest();
//then
AopException ex = replacedert.Throws<AopException>(() => client.CertificateExecute(request));
replacedert.AreEqual(ex.Message.Contains("检测到证书相关参数未初始化,非证书模式下请改为调用Execute"), true);
}
19
Source : WordTemplateTests.cs
with MIT License
from alkampfergit
with MIT License
from alkampfergit
[Test]
public void Verify_throws_on_null()
{
replacedert.Throws<ArgumentNullException>(() => new WordTemplateFolderManager(null));
}
19
Source : SingleSectionParserTests.cs
with MIT License
from alkampfergit
with MIT License
from alkampfergit
[Test]
public void Unknown_section_Will_throw()
{
replacedert.Throws<NotSupportedException>(() => ConfigurationParser.SectionParser.Parse("[[unknown section]]"));
}
19
Source : TemplateManagerTests.cs
with MIT License
from alkampfergit
with MIT License
from alkampfergit
[Test]
public void Verify_throw_if_folder_is_null()
{
replacedert.Throws<ArgumentNullException>(() => new TemplateManager(null));
}
19
Source : TemplateManagerTests.cs
with MIT License
from alkampfergit
with MIT License
from alkampfergit
[Test]
public void Verify_throw_if_folder_does_not_exists()
{
replacedert.Throws<ArgumentException>(() => new TemplateManager(GetTemplateFolder("this_does_not_exists")));
}
19
Source : TemplateManagerTests.cs
with MIT License
from alkampfergit
with MIT License
from alkampfergit
[Test]
public void Verify_throw_if_wrong_template_name_grabbed()
{
var sut = new TemplateManager(GetTemplateFolder("1"));
replacedert.Throws<ArgumentException>(() => sut.GetWordDefinitionTemplate("not exsists"));
}
19
Source : TestDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestInitializeWithDifferentRealAndImagSizes()
{
replacedert.Throws<ArgumentException>(() =>
{
var s = new ComplexDiscreteSignal(8000, new double[] { 1, 2 }, new double[] { 3 });
});
}
19
Source : TestDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSliceWrongRange()
{
replacedert.Multiple(() =>
{
replacedert.Throws<ArgumentException>(() => { var slice = _signal[5, 5]; });
replacedert.Throws<ArgumentException>(() => { var slice = _signal[5, 4]; });
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestInitializeWithBadSamplingRate()
{
replacedert.Multiple(() =>
{
replacedert.Throws<ArgumentException>(() => { var s = new ComplexDiscreteSignal(0, new double[] {1}); });
replacedert.Throws<ArgumentException>(() => { var s = new ComplexDiscreteSignal(-8000, new double[] {1}); });
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestInitializeWithDifferentRealAndImagSizes()
{
replacedert.Throws<ArgumentException>(() =>
{
var s = new ComplexDiscreteSignal(8000, new double[] { 1, 2 }, new double[] {3});
});
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestNegativeDelayTooBig()
{
replacedert.Throws<ArgumentException>(() => { _signal.Delay(-10); });
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSuperimposeWithDifferentSamplingRates()
{
replacedert.Throws<ArgumentException>(() => { _signal.Superimpose(_small); });
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestConcatenateWithDifferentSamplingRates()
{
replacedert.Throws<ArgumentException>(() => { _signal.Concatenate(_small); });
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestRepeatNegativeTimes()
{
replacedert.Throws<ArgumentException>(() => { _signal.Repeat(-2); });
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestRepeatZeroTimes()
{
replacedert.Throws<ArgumentException>(() => { var repeated = _signal.Repeat(0); });
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestSliceIndexOutOfRange()
{
replacedert.Throws<ArgumentException>(() => { var slice = _signal[5, 15]; });
}
19
Source : TestComplexDiscreteSignal.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestNegativeFirstOrLast()
{
replacedert.Multiple(() =>
{
replacedert.Throws<ArgumentException>(() => { var first = _signal.First(-3); });
replacedert.Throws<ArgumentException>(() => { var last = _signal.Last(-5); });
});
}
19
Source : TestFft.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestFftShiftOddSize()
{
float[] array = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
replacedert.Throws<ArgumentException>(() => Fft.Shift(array));
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestWrongRange()
{
replacedert.Throws<ArgumentException>(
() => { var cmap = new ColorMap(DefaultPalette, 1.0, 1.0); });
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestWrongNumberOfColors()
{
replacedert.Throws<ArgumentException>(
() => { var cmap = new ColorMap(DefaultPalette, 0.0, 1.0, 0); });
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestNullPaletteName()
{
replacedert.Throws<ArgumentException>(() => { var cmap = new ColorMap(null, 10, 100); });
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestUserDefinedColorPositionsNotNull()
{
replacedert.Throws<ArgumentException>(() => {
var cmap = ColorMap.CreateFromColors(_colors, null, -30, 30, 78);
});
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestUserDefinedColorsInconsistentWithPositions()
{
replacedert.Throws<ArgumentException>(() => {
var cmap = ColorMap.CreateFromColors(_colors, new [] { 0, 1.0f }, -30, 30, 78);
});
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestAtLeastTwoUserDefinedColors()
{
replacedert.Throws<ArgumentException>(() => {
var cmap = ColorMap.CreateFromColors(
new [] { new byte[] { 0, 0, 0 } }, new [] { 0.0f }, -30, 30, 78);
});
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestIncorrectRgbFormatOfUserDefinedColors()
{
replacedert.Throws<ArgumentException>(() => {
var cmap = ColorMap.CreateFromColors(
new [] {
new byte[] { 0, 0, 0 },
new byte[] { 0, 0 } // error here
},
new [] { 0, 1.0f },
-30, 30, 78);
});
}
19
Source : TestColorMap.cs
with MIT License
from ar1st0crat
with MIT License
from ar1st0crat
[Test]
public void TestWrongColorPositions()
{
replacedert.Throws<ArgumentException>(() => {
var cmap = ColorMap.CreateFromColors(_colors, new [] { 0, 0.5f, 1.2f }, -30, 30, 78);
});
}
19
Source : CodeProviderFactoryTests.cs
with MIT License
from arasplm
with MIT License
from arasplm
[Test]
public void Ctor_CodeFormatterIsNull_ShouldThrowArgumentNullException()
{
// replacedert
replacedert.Throws<ArgumentNullException>(new TestDelegate(() =>
{
// Act
var codeProviderFactory =
new CodeProviderFactory(null, messageManager, iOWrapper);
}), nameof(messageManager));
}
19
Source : CSharpCodeProviderTests.cs
with MIT License
from arasplm
with MIT License
from arasplm
[Test]
public void Ctor_CodeFormatter_ShouldDefaultCodeProviderThrowArgumentNullException()
{
replacedert.Throws<ArgumentNullException>(new TestDelegate(() =>
{
// Act
new CSharpCodeProvider(codeItemProvider, null, iOWrapper, messageManager);
}));
}
19
Source : AuthenticationCommandBaseTest.cs
with MIT License
from arasplm
with MIT License
from arasplm
[Test]
public void Ctor_CallCtorWithNullAuthManager_ShouldThrowArgumentNullException()
{
replacedert.Throws<ArgumentNullException>(new TestDelegate(() =>
{
// Act
new AuthenticationCommandBaseTest(null, dialogFactory, projectManager, projectConfigurationManager, codeProviderFactory, messageManager);
}));
}
19
Source : GlobalConfigurationTest.cs
with MIT License
from arasplm
with MIT License
from arasplm
[Test]
public void Ctor_ShouldThrowException()
{
//replacedert
replacedert.Throws<ArgumentNullException>(() =>
{
GlobalConfigurationTestProxy globalConfigurationTest = new GlobalConfigurationTestProxy(null);
});
}
See More Examples