-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests | Add test to SqlNotificationRequest to address code coverage (#…
- Loading branch information
1 parent
5bf73f1
commit 27c56af
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/Microsoft.Data.SqlClient/tests/FunctionalTests/SqlNotificationRequestTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using Microsoft.Data.Sql; | ||
using Xunit; | ||
|
||
namespace Microsoft.Data.SqlClient.Tests | ||
{ | ||
public class SqlNotificationRequestTest | ||
{ | ||
[Fact] | ||
public void SetOptions_OutOfRangeValue_Throws() | ||
{ | ||
SqlNotificationRequest sqlNotification = new(); | ||
string outOfRangeValue = new string('a', ushort.MaxValue + 1); | ||
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => sqlNotification.Options = outOfRangeValue); | ||
Assert.Null(ex.InnerException); | ||
Assert.NotNull(ex.ParamName); | ||
Assert.True(ex.ParamName.IndexOf("Options", StringComparison.OrdinalIgnoreCase) != -1); | ||
} | ||
|
||
[Fact] | ||
public void SetUserData_OutOfRangeValue_Throws() | ||
{ | ||
SqlNotificationRequest sqlNotification = new(); | ||
string outOfRangeValue = new string('a', ushort.MaxValue + 1); | ||
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => sqlNotification.UserData = outOfRangeValue); | ||
Assert.Null(ex.InnerException); | ||
Assert.NotNull(ex.ParamName); | ||
Assert.True(ex.ParamName.IndexOf("UserData", StringComparison.OrdinalIgnoreCase) != -1); | ||
} | ||
|
||
[Fact] | ||
public void SetTimeout_OutOfRangeValue_Throws() | ||
{ | ||
SqlNotificationRequest sqlNotification = new(); | ||
int outOfRangeValue = -1; | ||
ArgumentOutOfRangeException ex = Assert.Throws<ArgumentOutOfRangeException>(() => sqlNotification.Timeout = outOfRangeValue); | ||
Assert.Null(ex.InnerException); | ||
Assert.NotNull(ex.ParamName); | ||
Assert.True(ex.ParamName.IndexOf("Timeout", StringComparison.OrdinalIgnoreCase) != -1); | ||
} | ||
} | ||
} |