Here are the examples of the csharp api class 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.
200 Examples
0
1. Example
View license[Test] public void Test_Throws_Exception_If_Relative_Path_Points_Above_Root() { var from = new Resource(@"\spec\concordion\breadcrumbs\Breadcrumbs.html"); Assert.Throws<Exception>(delegate { from.GetRelativeResource(@"..\..\..\..\cocordion-logo.png"); }); }
0
2. Example
View license[Test] public void Should_throw_if_no_message_property_found_for_conventional_add() { // Arrange var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); // Act var @delegate = new TestDelegate(() => builder.Add(p => p.NoMessageProperty)); // Assert Assert.Throws<ArgumentOutOfRangeException>(@delegate); }
0
3. Example
View license[Test] public void Should_throw_if_no_message_property_found_for_conventional_mapping() { // Arrange var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); // Act var @delegate = new TestDelegate(() => builder.Map(p => p.NoMessageProperty)); // Assert Assert.Throws<ArgumentOutOfRangeException>(@delegate); }
0
4. Example
View license[Test] public void Should_throw_if_no_message_property_found_for_conventional_substract() { // Arrange var builder = new AddNewProjectionStrategyArguments<TestMessage, TestProjection>(); // Act var @delegate = new TestDelegate(() => builder.Substract(p => p.NoMessageProperty)); // Assert Assert.Throws<ArgumentOutOfRangeException>(@delegate); }
0
5. Example
View license[Test] public void BuildConfigurationWithNoFilePathTest() { Assert.Throws<NullReferenceException>(() => ExclusionHandler.HasValidExclusions("myconfig", null)); }
0
6. Example
View license[Test] public void BuildConfigurationWithInvalidFilePathTest() { Assert.Throws<FileNotFoundException>(() => ExclusionHandler.HasValidExclusions("myconfig", "invalidfile.xml")); }
0
7. Example
View license[Test] public void When_No_BucketCredentials_Defined_Throw_ArgumentException() { var config = TestConfiguration.GetCurrentConfiguration(); var cluster = new Cluster(config); var cred = new ClassicAuthenticator("Administrator", "password"); //cred.AddBucketCredential("buck", ""); //cred.AddBucketCredential("travel-sample", ""); Assert.Throws<ArgumentException>(()=>cluster.Authenticate(cred)); }
0
8. Example
View license[Test] public void Test_Peek_Throws_InvalidOperationException_When_Empty() { var key = "Test_Peek_Throws_InvalidOperationException_When_Empty"; _bucket.Remove(key); var queue = new CouchbaseQueue<Poco>(_bucket, key); Assert.Throws<InvalidOperationException>(() => queue.Peek()); }
0
9. Example
View license[Test] public void Test_Add_WhenExists_ThrowInvalidOperationException() { var collection = new CouchbaseSet<Poco>(_bucket, "Test_Add_WhenExists_ThrowInvalidOPerationException"); collection.Clear(); collection.Add(new Poco {Key = "poco1", Name = "Poco-pica"}); Assert.Throws<InvalidOperationException>(() => collection.Add(new Poco { Key = "poco1", Name = "Poco-pica" })); }
0
10. Example
View license[Test] public void GetDesignDocument_Throws_NotSupportedException() { Assert.Throws<NotSupportedException>(()=> _bucketManager.GetDesignDocument("test")); }
0
11. Example
View license[Test] public void GetDesignDocuments_Throws_NotSupportedException() { Assert.Throws<NotSupportedException>(() => _bucketManager.GetDesignDocuments()); }
0
12. Example
View license[Test] public void When_Get_Called_Without_Calling_Initialize_InitializationException_Is_Thrown() { ClusterHelper.Close(); var ex = Assert.Throws<InitializationException>(() => ClusterHelper.Get()); }
0
13. Example
View license[Test] public void When_GetBucket_Is_Called_And_NotInitialized_ThrowInitializationException() { Assert.Throws<InitializationException>(()=>ClusterHelper.GetBucket("default")); }
0
14. Example
View license[Test] public void Test_Query_WhenBucketOpenedThatIsNotInAuthenticator_Fails() { var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); var credentials = new ClusterCredentials { BucketCredentials = new Dictionary<string, string> { {"authenticated", "secret"} } }; cluster.Authenticate(credentials); Assert.Throws<AuthenticationException>(() => cluster.OpenBucket("default")); }
0
15. Example
View license[Test] public void Test_Query_WhenInvalidPassword_ThrowsException() { var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); var credentials = new ClusterCredentials { BucketCredentials = new Dictionary<string, string> { {"authenticated", "secret1"} } }; cluster.Authenticate(credentials); Assert.Throws<AggregateException>(()=>cluster.Query<dynamic>("select * from authenticated limit 1;")); }
0
16. Example
View license[Test] public void Test_Query_WhenAuthenticateNotCalled_ThrowsInvalidOperationException() { var cluster = new Cluster(TestConfiguration.GetCurrentConfiguration()); Assert.Throws<InvalidOperationException>(() => cluster.Query<dynamic>("select * from authenticated limit 1;")); }
0
17. Example
View license[Test] public void When_Query_Called_On_Memcached_Bucket_With_N1QL_NotSupportedException_Is_Thrown() { const string query = "SELECT * FROM tutorial WHERE fname = 'Ian'"; Assert.Throws<NotSupportedException>(() => _bucket.Query<dynamic>(query)); }
0
18. Example
View license[Test] public void When_Query_Called_On_Memcached_Bucket_With_ViewQuery_NotSupportedException_Is_Thrown() { var query = new ViewQuery(); Assert.Throws<NotSupportedException>(() => _bucket.Query<dynamic>(query)); }
0
19. Example
View license[Test] public void When_CreateQuery_Called_On_Memcached_Bucket_NotSupportedException_Is_Thrown() { Assert.Throws<NotSupportedException>(() => _bucket.CreateQuery("designdoc", "view", true)); }
0
20. Example
View license[Test] public void When_CreateQuery2_Called_On_Memcached_Bucket_NotSupportedException_Is_Thrown() { var ex = Assert.Throws<NotSupportedException>(() => _bucket.CreateQuery("designdoc", "view")); }
0
21. Example
View license[Test] public void When_CreateQuery3_Called_On_Memcached_Bucket_NotSupportedException_Is_Thrown() { var ex = Assert.Throws<NotSupportedException>(() => _bucket.CreateQuery("designdoc", "view", true)); }
0
22. Example
View license[Test] public void When_IOException_Occurs_Authenticate_Throws_Exception() { var authenticator = new CramMd5Mechanism("default", string.Empty, new DefaultTranscoder()); _ioService.ConnectionPool.Initialize(); var connection = _ioService.ConnectionPool.Acquire(); connection.Socket.Disconnect(false); Assert.Throws<SocketException>(() => authenticator.Authenticate(connection)); }
0
23. Example
View license[Test] public void When_IOException_Occurs_Authenticate_Throws_Exception() { var authenticator = new CramMd5Mechanism("default", string.Empty, new DefaultTranscoder()); var connection = _ioService.ConnectionPool.Acquire(); connection.Socket.Disconnect(false); Assert.Throws<IOException>(() => authenticator.Authenticate(connection)); }
0
24. Example
View license[Test] public void When_NotSupportedException_Thrown_When_Proxy_Port_Is_Configured() { var configuration = new ClientConfiguration {PoolConfiguration = new PoolConfiguration { MaxSize = 10, MinSize = 10 }}; configuration.Servers.Clear(); configuration.Servers.Add(new Uri("http://127.0.0.1:8091/pools")); var bc = new BucketConfiguration(); bc.Password = "secret"; bc.Username = "admin"; bc.BucketName = "authenticated"; bc.Servers.Clear(); bc.Servers.Add(new Uri("http://127.0.0.1:8091/pools")); bc.Port = 11211; configuration.BucketConfigs.Clear(); configuration.BucketConfigs.Add("authenticated", bc); Assert.Throws<NotSupportedException>(() => configuration.Initialize()); }
0
25. Example
View license[Test] public void When_Servers_Is_Empty_ArgumentNullException_Is_Thrown() { var couchbaseConfiguration = new ClientConfiguration(); couchbaseConfiguration.Servers.Clear(); Assert.Throws<ArgumentNullException>(() => couchbaseConfiguration.HasServersChanged()); }
0
26. Example
View license[Test] public void When_ScanConsistency_StatementPlus_Provided_NotSupportedException_Is_Thrown() { var query = new QueryRequest(); #pragma warning disable 618 Assert.Throws<NotSupportedException>(() => query.ScanConsistency(ScanConsistency.StatementPlus)); #pragma warning restore 618 }
0
27. Example
View license[TestCase] public void Throws_ArgumentException_When_QueryRequest_Statement_Is_Null_Or_Empty() { QueryRequest queryRequest; var log = new FakeLog("mylogger", LogLevel.Debug, true, true, true, LogDateFormat); queryRequest = new QueryRequest(null); Assert.Throws<ArgumentException>(() => new QueryTimer(queryRequest, new CommonLogStore(log), true), QueryTimer.QueryStatementMustBeProvided); queryRequest = new QueryRequest(string.Empty); Assert.Throws<ArgumentException>(() => new QueryTimer(queryRequest, new CommonLogStore(log), true), QueryTimer.QueryStatementMustBeProvided); }
0
28. Example
View license[TestCase] public void Throws_ArgumentException_When_QueryRequest_Is_Null() { var log = new FakeLog("mylogger", LogLevel.Debug, true, true, true, LogDateFormat); Assert.Throws<ArgumentException>(() => new QueryTimer(null, new CommonLogStore(log), true), QueryTimer.QueryMustBeProvided); }
0
29. Example
View license[Test] public void When_Get_Called_Without_Calling_Initialize_InitializationException_Is_Thrown() { ClusterHelper.Close(); var ex = Assert.Throws<InitializationException>(() => ClusterHelper.Get()); }
0
30. Example
View license[Test] public void Test_That_Bucket_That_Doesnt_Exist_Throws_ConfigException() { Assert.Throws<AggregateException>(() => _cluster.OpenBucket("authenicated", "secret")); }
0
31. Example
View license[Test] public void When_Query_Called_On_Memcached_Bucket_With_N1QL_NotSupportedException_Is_Thrown() { using (var bucket = _cluster.OpenBucket("memcached")) { const string query = "SELECT * FROM tutorial WHERE fname = 'Ian'"; Assert.Throws<NotSupportedException>(() => bucket.Query<dynamic>(query)); } }
0
32. Example
View license[Test] public void When_Query_Called_On_Memcached_Bucket_With_ViewQuery_NotSupportedException_Is_Thrown() { using (var bucket = _cluster.OpenBucket("memcached")) { var query = new ViewQuery(); Assert.Throws<NotSupportedException>(() => bucket.Query<dynamic>(query)); } }
0
33. Example
View license[Test] public void When_CreateQuery_Called_On_Memcached_Bucket_NotSupportedException_Is_Thrown() { using (var bucket = _cluster.OpenBucket("memcached")) { Assert.Throws<NotSupportedException>(() => bucket.CreateQuery("designdoc", "view", true)); } }
0
34. Example
View license[Test] public void When_CreateQuery2_Called_On_Memcached_Bucket_NotSupportedException_Is_Thrown() { using (var bucket = _cluster.OpenBucket("memcached")) { var ex = Assert.Throws<NotSupportedException>(() => bucket.CreateQuery("designdoc", "view")); } }
0
35. Example
View license[Test] public void When_CreateQuery3_Called_On_Memcached_Bucket_NotSupportedException_Is_Thrown() { using (var bucket = _cluster.OpenBucket("memcached")) { var ex = Assert.Throws<NotSupportedException>(() => bucket.CreateQuery("designdoc", "view", true)); } }
0
36. Example
View license[Test] public void Null_Authenticator_Throws_NullArgumentException() { var cluster = new Cluster(); Assert.Throws<ArgumentNullException>(() => cluster.Authenticate((IAuthenticator) null)); }
0
37. Example
View license[Test] public void ScramShaMechanism_WhenTranscoderIsNullinCtor_ThrowArgumentNullException() { ITypeTranscoder transcoder = null; // ReSharper disable once ExpressionIsAlwaysNull // ReSharper disable once ObjectCreationAsStatement Assert.Throws<ArgumentNullException>(() => new ScramShaMechanism(transcoder, MechanismType.ScramSha256)); }
0
38. Example
View license[Test] [TestCase("")] [TestCase(" ")] [TestCase(null)] public void ScramShaMechanism_WhenUsernameIsInvalidinCtor_ThrowArgumentNullException(string username) { var transcoder = new DefaultTranscoder(new DefaultConverter()); string password = null; // ReSharper disable once ExpressionIsAlwaysNull // ReSharper disable once ObjectCreationAsStatement // ReSharper disable once ExpressionIsAlwaysNull Assert.Throws<ArgumentNullException>(() => new ScramShaMechanism(transcoder, username, password, MechanismType.ScramSha256)); }
0
39. Example
View license[Test] [TestCase("PLAIN")] [TestCase("CRAM-MD5")] public void ScramShaMechanism_WhenMechanismIsInavlid_ThrowArgumentOutOfRangeException(string mechanismType) { ITypeTranscoder transcoder = new DefaultTranscoder(new DefaultConverter()); string username = "beef"; string password = "stew"; // ReSharper disable once ExpressionIsAlwaysNull // ReSharper disable once ObjectCreationAsStatement Assert.Throws<ArgumentOutOfRangeException>(() => new ScramShaMechanism(transcoder, username, password, mechanismType)); }
0
40. Example
View license[Test] [TestCase("")] [TestCase(" ")] [TestCase(null)] public void ScramShaMechanism_WhenMechanismIsInavlid_ThrowArgumentNullException(string mechanismType) { ITypeTranscoder transcoder = new DefaultTranscoder(new DefaultConverter()); string username = "beef"; string password = "stew"; // ReSharper disable once ExpressionIsAlwaysNull // ReSharper disable once ObjectCreationAsStatement Assert.Throws<ArgumentNullException>(() => new ScramShaMechanism(transcoder, username, password, mechanismType)); }
0
41. Example
View license[TestCase(0, 1, Description = "MaxSize is less than 1")] [TestCase(501, 1, Description = "MaxSize is greater than 500")] [TestCase(1, -1, Description = "MinSize is less than 0")] [TestCase(501, 501, Description = "MinSize is greater than 500")] [TestCase(5, 10, Description = "Maxsize is greater than MinSize")] public void Throws_Argument_Exception_If_Connection_Values_Are_Not_Valid(int maxSize, int minSize) { Assert.Throws<ArgumentOutOfRangeException>(() => new ClientConfiguration { PoolConfiguration = new PoolConfiguration { MaxSize = maxSize, MinSize = minSize } }.Initialize()); }
0
42. Example
View license[TestCase(0, 1, Description = "MaxSize is less than 1")] [TestCase(501, 1, Description = "MaxSize is greater than 500")] [TestCase(1, -1, Description = "MinSize is less than 0")] [TestCase(501, 501, Description = "MinSize is greater than 500")] [TestCase(5, 10, Description = "Maxsize is greater than MinSize")] public void Throws_Argument_Exception_If_Connection_Values_Are_Not_Valid_For_BucketConfigs(int maxSize, int minSize) { Assert.Throws<ArgumentOutOfRangeException>(() => new ClientConfiguration { BucketConfigs = new Dictionary<string, BucketConfiguration> { { "default", new BucketConfiguration { PoolConfiguration = new PoolConfiguration { MaxSize = maxSize, MinSize = minSize } } } } }.Initialize()); }
0
43. Example
View license[Test] public void When_HeartbeatConfigInterval_Is_Less_Than_HeartbeatConfigCheckFloor_Throw_ArgumentOutOfRangeException() { var clientConfig = new ClientConfiguration { HeartbeatConfigCheckFloor = 500, HeartbeatConfigInterval = 10 }; Assert.Throws<ArgumentOutOfRangeException>(() => clientConfig.Initialize()); }
0
44. Example
View license[Test] public void When_HeartbeatConfigInterval_Are_Equal_HeartbeatConfigCheckFloor_Throw_ArgumentOutOfRangeException() { var clientConfig = new ClientConfiguration { HeartbeatConfigCheckFloor = 500, HeartbeatConfigInterval = 500 }; Assert.Throws<ArgumentOutOfRangeException>(() => clientConfig.Initialize()); }
0
45. Example
View license[TestCase(0, 1, Description = "MaxSize is less than 1")] [TestCase(501, 1, Description = "MaxSize is greater than 500")] [TestCase(1, -1, Description = "MinSize is less than 0")] [TestCase(501, 501, Description = "MinSize is greater than 500")] [TestCase(5, 10, Description = "Maxsize is greater than MinSize")] public void Throws_Argument_Exception_If_Connection_Values_Are_Not_Valid(int maxSize, int minSize) { Assert.Throws<ArgumentOutOfRangeException>(() => new PoolConfiguration { MaxSize = maxSize, MinSize = minSize }.Validate()); }
0
46. Example
View license[Test] public void Visit_DoesntUseParameter_ThrowsException() { // Arrange Expression<Func<Document, string>> expression = p => "key"; // Act/Assert Assert.Throws<NotSupportedException>(() => SubDocumentPathExpressionVisitor.GetPath(new DefaultSerializer(), expression)); }
0
47. Example
View license[Test] public void Visit_ParameterAsArrayIndex_ThrowsException() { // Arrange Expression<Func<Document, string>> expression = p => p.StringDictionary[p.StringProperty]; // Act/Assert Assert.Throws<NotSupportedException>(() => SubDocumentPathExpressionVisitor.GetPath(new DefaultSerializer(), expression)); }
0
48. Example
View license[Test] public void Visit_TwoDimensionalIndexedProperty_ThrowsException() { // Arrange Expression<Func<Document, string>> expression = p => p.SubDocument[1, 2]; // Act/Assert Assert.Throws<NotSupportedException>(() => SubDocumentPathExpressionVisitor.GetPath(new DefaultSerializer(), expression)); }
0
49. Example
View license[Test] public void GetMemberName_Null_ArgumentNullException() { // Arrange var serializer = new DefaultSerializer(); // Act/Assert Assert.Throws<ArgumentNullException>(() => serializer.GetMemberName(null)); }
0
50. Example
View license[Test] public void Parse_BadVersion_ThrowsFormatException() { // Act/Assert Assert.Throws<FormatException>(() => ClusterVersion.Parse("abcd")); }