|
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | 4 |
|
5 | 5 | using System; |
| 6 | +using System.Collections.Generic; |
6 | 7 | using System.Data; |
7 | 8 | using System.Data.Common; |
| 9 | +using System.Reflection; |
| 10 | +using System.Threading; |
8 | 11 | using Xunit; |
9 | 12 |
|
10 | 13 | namespace Microsoft.Data.SqlClient.Tests |
@@ -64,6 +67,8 @@ public void CatalogSeparator() |
64 | 67 | { |
65 | 68 | SqlCommandBuilder cb = new SqlCommandBuilder(); |
66 | 69 | Assert.Equal(".", cb.CatalogSeparator); |
| 70 | + cb.CatalogSeparator = "."; |
| 71 | + Assert.Equal(".", cb.CatalogSeparator); |
67 | 72 | } |
68 | 73 |
|
69 | 74 | [Theory] |
@@ -124,6 +129,23 @@ public void ConflictOption_Value_Invalid() |
124 | 129 | Assert.Equal(ConflictOption.CompareRowVersion, cb.ConflictOption); |
125 | 130 | } |
126 | 131 |
|
| 132 | + [Fact] |
| 133 | + public void DataAdapter() |
| 134 | + { |
| 135 | + SqlCommandBuilder cb = new SqlCommandBuilder(); |
| 136 | + Assert.Null(cb.DataAdapter); |
| 137 | + |
| 138 | + cb.DataAdapter = new SqlDataAdapter(); |
| 139 | + Assert.NotNull(cb.DataAdapter); |
| 140 | + } |
| 141 | + |
| 142 | + [Theory] |
| 143 | + [MemberData(nameof(SqlTestCommands))] |
| 144 | + public void DeriveParameters_Throws(Type ex, SqlCommand command) |
| 145 | + { |
| 146 | + Assert.Throws(ex, () => SqlCommandBuilder.DeriveParameters(command)); |
| 147 | + } |
| 148 | + |
127 | 149 | [Fact] |
128 | 150 | public void QuoteIdentifier() |
129 | 151 | { |
@@ -323,5 +345,19 @@ public void SchemaSeparator_Value_Invalid(string separator) |
323 | 345 | Assert.Null(ex.ParamName); |
324 | 346 | } |
325 | 347 | } |
| 348 | + |
| 349 | + #region member data |
| 350 | + public static IEnumerable<object[]> SqlTestCommands => |
| 351 | + new List<object[]> |
| 352 | + { |
| 353 | + new object[] { typeof(ArgumentNullException), null }, |
| 354 | + /* TODO: may need a MOQ class for DbCommand to override the DeriveParameters to throw these exceptions |
| 355 | + new object[] { typeof(OutOfMemoryException), new SqlCommand() }, |
| 356 | + new object[] { typeof(StackOverflowException), new SqlCommand() }, |
| 357 | + new object[] { typeof(ThreadAbortException), new SqlCommand() }, |
| 358 | + new object[] { typeof(Exception), new SqlCommand() } |
| 359 | + */ |
| 360 | + }; |
| 361 | + #endregion |
326 | 362 | } |
327 | 363 | } |
0 commit comments