Here are the examples of the csharp api class NUnit.Framework.Assert.Throws(NUnit.Framework.TestDelegate, string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
142 Examples
0
1. Example
View license[TestCase(null)] [TestCase("")] [TestCase(" ")] public void Test_Empty_Key_Throws_KeyException(string key) { Assert.Throws<MissingKeyException>(() => new FakeMultiLookupOperation<dynamic>(key, null, null, null, 0), "Key cannot be empty."); }
0
2. Example
View license[TestCase(null)] [TestCase("")] [TestCase(" ")] public void Test_Empty_Key_Throws_KeyException(string key) { Assert.Throws<MissingKeyException>(() => new FakeMultiMutationOperation<dynamic>(key, null, null, null, 0), "Key cannot be empty."); }
0
3. Example
View license[TestCase(null)] [TestCase("")] [TestCase(" ")] public void Test_Empty_Key_Throws_KeyException(string key) { Assert.Throws<MissingKeyException>(() => new FakeSubDocumentOperation<dynamic>(null, key, null, null, 0), "Key cannot be empty."); }
0
4. Example
View license[Test] public void UnderlyingGetter () { var i = new XamlMemberInvoker (new MyXamlMember (str_len, sctx)); // call XamlMember's UnderlyingGetter. Assert.Throws<MyException> (() => { var t = i.UnderlyingGetter; }, "#1"); }
0
5. Example
View license[Test] public void UnderlyingSetter () { var i = new XamlMemberInvoker (new MyXamlMember (str_len, sctx)); // call XamlMember's UnderlyingSetter. Assert.Throws<MyException> (() => { var t = i.UnderlyingSetter; }, "#1"); }
0
6. Example
View license[Test] public void SetHandleMarkupExtensionInvalid () { var i = new XamlTypeInvoker (new XamlType (typeof (TestClassMarkupExtension1), sctx)); Assert.Throws<ArgumentException> (() => { var t = i.SetMarkupExtensionHandler; }, "#1"); }
0
7. Example
View license[Test] public void SetHandleMarkupExtensionInvalid2 () { var i = new XamlTypeInvoker (new XamlType (typeof (TestClassMarkupExtension2), sctx)); Assert.Throws<ArgumentException> (() => { var t = i.SetMarkupExtensionHandler; }, "#1"); }
0
8. Example
View license[Test] public void SetHandleMarkupExtensionInvalid3 () { var i = new XamlTypeInvoker (new XamlType (typeof (TestClassMarkupExtension3), sctx)); Assert.Throws<ArgumentException> (() => { var t = i.SetMarkupExtensionHandler; }, "#1"); }
0
9. Example
View license[Test] public void SetHandleTypeConverterInvalid () { var i = new XamlTypeInvoker (new XamlType (typeof (TestClassTypeConverter1), sctx)); Assert.Throws<ArgumentException> (() => { var t = i.SetTypeConverterHandler; }, "#1"); }
0
10. Example
View license[Test] public void SetHandleTypeConverterInvalid2 () { var i = new XamlTypeInvoker (new XamlType (typeof (TestClassTypeConverter2), sctx)); Assert.Throws<ArgumentException> (() => { var t = i.SetTypeConverterHandler; }, "#1"); }
0
11. Example
View license[Test] public void SetHandleTypeConverterInvalid3 () { var i = new XamlTypeInvoker (new XamlType (typeof (TestClassTypeConverter3), sctx)); Assert.Throws<ArgumentException> (() => { var t = i.SetTypeConverterHandler; }, "#1"); }
0
12. Example
View license[Test] public void InconsistentConverterType () { var c = new XamlValueConverter<TypeConverter> (typeof (int), XamlLanguage.String, null); Assert.Throws<XamlSchemaException> (() => { var t = c.ConverterInstance; }, "#1"); }
0
13. Example
View license[Test(Description = "This checks whether setting a null value as Center throws an ArgumentNullException.")] public void ExtentSetCenterNullCoordinateTest() { Extent e = new Extent(); Assert.Throws<ArgumentNullException>(delegate { e.SetCenter(null); }, "ExtentSetCenter throws on null Coordinate"); Assert.Throws<ArgumentNullException>(delegate { e.SetCenter(null, 3, 4); }, "ExtentSetCenter with height and width throws on null Coordinate"); }
0
14. Example
View license[Test] public void TestConfigSet() { var c = new Config(); Assert.Throws<Exception>(() => c.Set("not a real config value", new object()), "No error when setting an invalid value"); }
0
15. Example
View license[Test] public void ThrowActualExceptionInsteadOfTargetInvocationException() { Script task = new Script(); task.BuildEngine = new MockBuild(); task.Code = @"public static void ScriptMain(){ throw new InvalidOperationException(""This is the actual exception.""); }"; Assert.Throws<InvalidOperationException>(() =>task.Execute(), "Task should have succeeded."); }
0
16. Example
View license[Test] public void FieldOrderWithSameNumber1() { Assert.Throws<BadUsageException> ( () => new FileHelperEngine<FieldOrderSameNumber1>(), "The field: Field5 has the same FieldOrder that: Field3 you must use different values" ); }
0
17. Example
View license[Test] public void FieldOrderWithSameNumber2() { Assert.Throws<BadUsageException> ( () => new FileHelperEngine<FieldOrderSameNumber2>(), "The field: Field2 has the same FieldOrder that: Field1 you must use different values" ); }
0
18. Example
View license[Test] public void PartialFieldOrderAppliedMiddle() { Assert.Throws<BadUsageException> ( () => new FileHelperEngine<FieldOrderPartialAppliedMiddle>(), "The field: Field3 must be marked with FielOrder because if you use this attribute in one field you must also use it in all." ); }
0
19. Example
View license[Test] public void PartialFieldOrderAppliedLast() { Assert.Throws<BadUsageException> ( () => new FileHelperEngine<FieldOrderPartialAppliedLast>(), "The field: Field5 must be marked with FielOrder because if you use this attribute in one field you must also use it in all." ); }
0
20. Example
View license[Test] public void PartialFieldOrderAppliedFirst() { Assert.Throws<BadUsageException> ( () => new FileHelperEngine<FieldOrderPartialAppliedFirst>(), "The field: Field1 must be marked with FielOrder because if you use this attribute in one field you must also use it in all." ); }
0
21. Example
View license[Test] public void FieldOptionalPlusFieldOrderWrong1() { Assert.Throws<BadUsageException> ( () => new FileHelperEngine<FieldOptionalPlusFieldOrderTypeWrong1>(), "" ); }
0
22. Example
View license[Test] public void FieldOptionalPlusFieldOrderWrong2() { Assert.Throws<BadUsageException> ( () => new FileHelperEngine<FieldOptionalPlusFieldOrderTypeWrong2>(), "" ); }
0
23. Example
View license[Test] public void OptionalWithAutoProps() { Assert.Throws<BadUsageException>(() => new FileHelperEngine<OptionalWithAutoPropsType>(), "You must only use all standard fields or all automatic properties, but you can't mix them like in the OptionalWithAutoPropsType class."); }
0
24. Example
View license[Test] public void Test_NullPropertyTest() { const string xml = "<project><property name='temp.var' value='some.value'/></project>"; Project p = CreateFilebasedProject(xml); PropertyDictionary d = new PropertyDictionary(p); TestDelegate assn = delegate() { d["temp.var"] = null; }; Assert.Throws<BuildException>(assn, "Null values should not be allowed in PropertyDictionary"); }
0
25. Example
View license[Test] public void InvokingBehaviour_GivenAggregateWithInvariantLogic_ShouldFailIfInvariantIsNotSatisfied() { // Arrange var user = new User(); user.Register(); user.ChangePassword("newpassword"); // Act / Assert Assert.Throws<InvalidOperationException>(() => user.ChangePassword("newpassword"), "Expected exception stating the new password must be different the the previous one."); }
0
26. Example
View license[Test] public void ApplyingPreviouslyGeneratedEvents_GivenNewAggregateObject_ShouldBringAggregateBackToPreviousState() { // Arrange var user = new User(); user.Register(); var events = new object[] {new UserRegistered(user.Id), new UserChangedPassword("newpassword"), new UserChangedPassword("newerpassword") }; // Act user.ApplyAll(events); // Assert Assert.Throws<InvalidOperationException>(() => user.ChangePassword("newerpassword"), "Expected exception stating the new password must be different the the previous one, indicating that previous events have replayed successfully."); }
0
27. Example
View license[Test] public void PlatformAttribute_InvalidPlatform() { PlatformAttribute attr = new PlatformAttribute( "Net-1.0,Net11,Mono" ); Assert.Throws<InvalidPlatformException>( () => winXPHelper.IsPlatformSupported(attr), "Invalid platform name Net11"); }
0
28. Example
View license[Test] public void AssociatePublication_BadArgsTests() { Assert.Throws<ArgumentNullException>(() => _controller.AssociatePublication(null, null), "No configuration to associate with"); Assert.Throws<ArgumentNullException>(() => _controller.AssociatePublication("publicationA", null), "No configuration to associate with"); Assert.Throws<ArgumentNullException>(() => _controller.AssociatePublication(null, _configurations[0]), "Don't allow trying to add null"); Assert.Throws<ArgumentOutOfRangeException>(() => _controller.AssociatePublication("unknown publication", _configurations[0]), "Don't associate with an invalid/unknown publication"); }
0
29. Example
View license[Test] public void DisassociatePublication_BadArgsTests() { Assert.Throws<ArgumentNullException>(() => _controller.DisassociatePublication(null, null), "No configuration to disassociate. No publication to disassociate from."); Assert.Throws<ArgumentNullException>(() => _controller.DisassociatePublication("publicationA", null), "No configuration"); Assert.Throws<ArgumentNullException>(() => _controller.DisassociatePublication(null, _configurations[0]), "No publication"); Assert.Throws<ArgumentOutOfRangeException>(() => _controller.DisassociatePublication("unknown publication", _configurations[0]), "Don't try to operate using an invalid/unknown publication"); }
0
30. Example
View license[Test] public void DeleteConfigurationCrashesOnNullArgument() { Assert.Throws<ArgumentNullException>(() => _controller.DeleteConfiguration(null), "Failed to throw"); }
0
31. Example
View license[Test] public void NullConfig() { IAopProxyFactory apf = new DefaultAopProxyFactory(); Assert.Throws<AopConfigException>(() => apf.CreateAopProxy(null),"Cannot create IAopProxy with null ProxyConfig" ); }
0
32. Example
View license[Test] public void IntroductionMustImplementIntroducedInterfaces() { DefaultIntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new TestIntroductionAdvice(), typeof(ICloneable)); Assert.Throws<ArgumentException>(() => advisor.ValidateInterfaces(), "Introduction [Spring.Aop.Support.DefaultIntroductionAdvisorTests+TestIntroductionAdvice] does not implement interface 'System.ICloneable' specified in introduction advice."); }
0
33. Example
View license[Test] public void ConvertFromBadKeyString() { RegistryKeyConverter rkc = new RegistryKeyConverter(); Assert.Throws<ArgumentException>(() => rkc.ConvertFrom(@"HKEY_CURRENT_USER\sdgsdfgsdfgxadas\Xyz\Abc"), @"Registry key [HKEY_CURRENT_USER\sdgsdfgsdfgxadas] does not exist."); }
0
34. Example
View license[Test] public void ConvertFromBadHiveString() { RegistryKeyConverter rkc = new RegistryKeyConverter(); Assert.Throws<ArgumentException>(() => rkc.ConvertFrom(@"HKEY_ERROR\sdgsdfgsdfgxadas"), "Invalid root hive name [HKEY_ERROR]."); }
0
35. Example
View license[Test] public void SetTargetDictionaryTypeToNonDictionaryType() { DictionaryFactoryObject dfo = new DictionaryFactoryObject(); Assert.Throws<ArgumentException>(() => dfo.TargetDictionaryType = typeof (ICollection), "The Type passed to the TargetDictionaryType property must implement the 'System.Collections.IDictionary' interface."); }
0
36. Example
View license[Test] public void SetTargetDictionaryTypeToDerivedIDictionaryInterfaceType() { DictionaryFactoryObject dfo = new DictionaryFactoryObject(); Assert.Throws<ArgumentException>(() => dfo.TargetDictionaryType = typeof (IExtendedDictionary), "The Type passed to the TargetDictionaryType property cannot be an interface; it must be a concrete class that implements the 'System.Collections.IDictionary' interface."); }
0
37. Example
View license[Test] public void SetTargetDictionaryTypeToAbstractIDictionaryInterfaceType() { DictionaryFactoryObject dfo = new DictionaryFactoryObject(); Assert.Throws<ArgumentException>(() => dfo.TargetDictionaryType = typeof (AbstractDictionary), "The Type passed to the TargetDictionaryType property cannot be abstract (MustInherit in VisualBasic.NET); it must be a concrete class that implements the 'System.Collections.IDictionary' interface."); }
0
38. Example
View license[Test] public void GetObjectWithoutSupplyingASourceDictionary() { DictionaryFactoryObject dfo = new DictionaryFactoryObject(); dfo.IsSingleton = false; Assert.Throws<ArgumentException>(() => dfo.GetObject(), "The 'SourceDictionary' property cannot be null (Nothing in Visual Basic.NET)."); }
0
39. Example
View license[Test] public void SetTargetListTypeToNonListType() { ListFactoryObject lfo = new ListFactoryObject(); Assert.Throws<ArgumentException>(() => lfo.TargetListType = typeof (ICollection), "The Type passed to the TargetListType property must implement the 'System.Collections.IList' interface."); }
0
40. Example
View license[Test] public void SetTargetListTypeToDerivedIListInterfaceType() { ListFactoryObject lfo = new ListFactoryObject(); Assert.Throws<ArgumentException>(() => lfo.TargetListType = typeof (IExtendedList), "The Type passed to the TargetListType property cannot be an interface; it must be a concrete class that implements the 'System.Collections.IList' interface."); }
0
41. Example
View license[Test] public void SetTargetListTypeToAbstractIListInterfaceType() { ListFactoryObject lfo = new ListFactoryObject(); Assert.Throws<ArgumentException>(() => lfo.TargetListType = typeof (AbstractList), "The Type passed to the TargetListType property cannot be abstract (MustInherit in VisualBasic.NET); it must be a concrete class that implements the 'System.Collections.IList' interface."); }
0
42. Example
View license[Test] public void GetObjectWithoutSupplyingASourceList() { ListFactoryObject lfo = new ListFactoryObject(); lfo.IsSingleton = false; Assert.Throws<ArgumentException>(() => lfo.GetObject(), "The 'SourceList' property cannot be null (Nothing in Visual Basic.NET)."); }
0
43. Example
View license[Test] public void CheckAfterPropertiesSetBlowsUpIfNotCorrectlyConfigured() { LogFactoryObject fac = new LogFactoryObject(); Assert.Throws<ArgumentException>(() => fac.AfterPropertiesSet(), "The 'LogName' property has not been set."); }
0
44. Example
View license[Test] public void GetSupertypesTooManyArgs() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); mcfo.TargetType = typeof (TestClass1); mcfo.TargetMethod = "Supertypes2"; mcfo.Arguments = new Object[] {new ArrayList(), new ArrayList(), "hello", "bogus"}; Assert.Throws<ArgumentException>(() => mcfo.AfterPropertiesSet(), "Unable to determine which exact method to call; found '2' matches."); }
0
45. Example
View license[Test] public void BailsIfTheTargetMethodPropertyAintSet() { MethodInvokingFactoryObject mcfo = new MethodInvokingFactoryObject(); Assert.Throws<ArgumentException>(() => mcfo.AfterPropertiesSet(), "The 'TargetMethod' property is required."); }
0
46. Example
View license[Test] public void WithMissingObjectName() { ObjectFactoryCreatingFactoryObject factory = new ObjectFactoryCreatingFactoryObject(); Assert.Throws<ArgumentException>(() => factory.AfterPropertiesSet(), "The 'TargetObjectName' property must have a value."); }
0
47. Example
View license[Test] public void WithUnresolvableEnvironmentProperty() { StaticApplicationContext ac = new StaticApplicationContext(); MutablePropertyValues pvs = new MutablePropertyValues(); pvs.Add("touchy", "${PROCESSOR_ARCHITECTURE}"); ac.RegisterSingleton("to", typeof (TestObject), pvs); pvs = new MutablePropertyValues(); pvs.Add("environmentVariableMode", EnvironmentVariableMode.Never); ac.RegisterSingleton("configurer", typeof (PropertyPlaceholderConfigurer), pvs); Assert.Throws<ObjectDefinitionStoreException>(() => ac.Refresh(), "Error registering object with name 'to' defined in '' : Could not resolve placeholder 'PROCESSOR_ARCHITECTURE'."); }
0
48. Example
View license[Test] public void BailsWhenNotConfigured() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); Assert.Throws<ArgumentException>(() => fac.AfterPropertiesSet(), "One of the TargetType or TargetObject properties must be set."); }
0
49. Example
View license[Test] public void BailsWhenJustTargetObjectIsSet() { PropertyRetrievingFactoryObject fac = new PropertyRetrievingFactoryObject(); fac.TargetObject = this; Assert.Throws<ArgumentException>(() => fac.AfterPropertiesSet(), "The TargetProperty property is required."); }
0
50. Example
View license[Test] public void SetTargetSetTypeToNonSetType() { SetFactoryObject lfo = new SetFactoryObject(); Assert.Throws<ArgumentException>(() => lfo.TargetSetType = typeof (ICollection), "The Type passed to the TargetSetType property must implement the 'Spring.Collections.ISet' interface."); }