This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SqlClientFactory: Override CreateDataAdapter (#19682)
* SqlClientFactory: Override CreateDataAdapter Override CreateDataAdapter and add tests. * Address CR feedback
- Loading branch information
1 parent
9ee2ac6
commit 88f562c
Showing
4 changed files
with
49 additions
and
8 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
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
43 changes: 43 additions & 0 deletions
43
src/System.Data.SqlClient/tests/FunctionalTests/SqlClientFactoryTest.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,43 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using Xunit; | ||
|
||
namespace System.Data.SqlClient.Tests | ||
{ | ||
public class SqlClientFactoryTest | ||
{ | ||
[Fact] | ||
public void InstanceTest() | ||
{ | ||
SqlClientFactory instance = SqlClientFactory.Instance; | ||
Assert.NotNull(instance); | ||
Assert.Same(instance, SqlClientFactory.Instance); | ||
} | ||
|
||
public static readonly object[][] FactoryMethodTestData = | ||
{ | ||
new object[] { new Func<object>(SqlClientFactory.Instance.CreateCommand), typeof(SqlCommand) }, | ||
new object[] { new Func<object>(SqlClientFactory.Instance.CreateConnection), typeof(SqlConnection) }, | ||
new object[] { new Func<object>(SqlClientFactory.Instance.CreateConnectionStringBuilder), typeof(SqlConnectionStringBuilder) }, | ||
new object[] { new Func<object>(SqlClientFactory.Instance.CreateDataAdapter), typeof(SqlDataAdapter) }, | ||
new object[] { new Func<object>(SqlClientFactory.Instance.CreateParameter), typeof(SqlParameter) }, | ||
}; | ||
|
||
[Theory] | ||
[MemberData(nameof(FactoryMethodTestData))] | ||
public void FactoryMethodTest(Func<object> factory, Type expectedType) | ||
{ | ||
object value1 = factory(); | ||
Assert.NotNull(value1); | ||
Assert.IsType(expectedType, value1); | ||
|
||
object value2 = factory(); | ||
Assert.NotNull(value2); | ||
Assert.IsType(expectedType, value2); | ||
|
||
Assert.NotSame(value1, value2); | ||
} | ||
} | ||
} |
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
88f562c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是对ado.net的支持吧。。。