|
| 1 | +using System; |
| 2 | +using Microsoft.Data.Sql; |
| 3 | +using Xunit; |
| 4 | + |
| 5 | +namespace Microsoft.Data.SqlClient.Tests |
| 6 | +{ |
| 7 | + public class SqlNotificationRequestTest |
| 8 | + { |
| 9 | + [Fact] |
| 10 | + public void SetOptions_OutOfRangeValue_Throws() |
| 11 | + { |
| 12 | + SqlNotificationRequest sqlNotification = new(); |
| 13 | + string outOfRangeValue = new string('a', ushort.MaxValue + 1); |
| 14 | + ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => sqlNotification.Options = outOfRangeValue); |
| 15 | + Assert.Null(ex.InnerException); |
| 16 | + Assert.NotNull(ex.ParamName); |
| 17 | + Assert.True(ex.ParamName.IndexOf("Options", StringComparison.OrdinalIgnoreCase) != -1); |
| 18 | + } |
| 19 | + |
| 20 | + [Fact] |
| 21 | + public void SetUserData_OutOfRangeValue_Throws() |
| 22 | + { |
| 23 | + SqlNotificationRequest sqlNotification = new(); |
| 24 | + string outOfRangeValue = new string('a', ushort.MaxValue + 1); |
| 25 | + ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => sqlNotification.UserData = outOfRangeValue); |
| 26 | + Assert.Null(ex.InnerException); |
| 27 | + Assert.NotNull(ex.ParamName); |
| 28 | + Assert.True(ex.ParamName.IndexOf("UserData", StringComparison.OrdinalIgnoreCase) != -1); |
| 29 | + } |
| 30 | + |
| 31 | + [Fact] |
| 32 | + public void SetTimeout_OutOfRangeValue_Throws() |
| 33 | + { |
| 34 | + SqlNotificationRequest sqlNotification = new(); |
| 35 | + int outOfRangeValue = -1; |
| 36 | + ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => sqlNotification.Timeout = outOfRangeValue); |
| 37 | + Assert.Null(ex.InnerException); |
| 38 | + Assert.NotNull(ex.ParamName); |
| 39 | + Assert.True(ex.ParamName.IndexOf("Timeout", StringComparison.OrdinalIgnoreCase) != -1); |
| 40 | + } |
| 41 | + } |
| 42 | +} |
0 commit comments