Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,9 @@
<NetStandardDriver Include="**/netcore/ref/Microsoft.Data.SqlClient*.csproj" />
<AKVProvider Include="**/add-ons/**/AzureKeyVaultProvider/*.csproj" />

<UnitTests Include="**/Common/Common.csproj" />
Comment thread
benrr101 marked this conversation as resolved.
<UnitTests Include="**/tools/TDS/TDS/TDS.csproj" />
<UnitTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
<UnitTests Include="**/tools/TDS/TDS.Servers/TDS.Servers.csproj" />
<UnitTests Include="**/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj" />
<UnitTestsProj Include="**/UnitTests/Microsoft.Data.SqlClient.UnitTests.csproj" />


<FunctionalTests Include="**/Common/Common.csproj" />
<FunctionalTests Include="**/tools/TDS/TDS/TDS.csproj" />
<FunctionalTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
Expand Down
15 changes: 15 additions & 0 deletions src/Microsoft.Data.SqlClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SqlClient.Stress.Tests", "M
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Data.SqlClient.Samples", "..\doc\Samples\Microsoft.Data.SqlClient.Samples.csproj", "{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Data.SqlClient.TestCommon", "Microsoft.Data.SqlClient\tests\Common\Microsoft.Data.SqlClient.TestCommon.csproj", "{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -657,6 +659,18 @@ Global
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Release|x64.ActiveCfg = Release|x64
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277}.Release|x86.ActiveCfg = Release|x86
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Debug|x64.ActiveCfg = Debug|x64
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Debug|x64.Build.0 = Debug|x64
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Debug|x86.ActiveCfg = Debug|x86
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Debug|x86.Build.0 = Debug|x86
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Release|Any CPU.Build.0 = Release|Any CPU
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Release|x64.ActiveCfg = Release|x64
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Release|x64.Build.0 = Release|x64
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Release|x86.ActiveCfg = Release|x86
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -714,6 +728,7 @@ Global
{4A9C11F4-9577-ABEC-C070-83A194746D9B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{FAA1E517-581A-D3DC-BAC9-FAD1D5A5142C} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{C09B9D2F-E463-BEBD-34E4-E8F2C201A277} = {ED952CF7-84DF-437A-B066-F516E9BE1C2C}
{3FF03FA9-E3C3-49E3-9DCB-C703A5B0278B} = {0CC4817A-12F3-4357-912C-09315FAAD008}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {01D48116-37A2-4D33-B9EC-94793C702431}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@
<KeyFile>$(SigningKeyPath)</KeyFile>
</PropertyGroup>


<!-- Internals visible to ============================================ -->
<ItemGroup Condition="'$(CDP_BUILD_TYPE)' != 'Official'">
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>UnitTests</_Parameter1>
Comment thread
benrr101 marked this conversation as resolved.
</AssemblyAttribute>
</ItemGroup>
Comment thread
paulmedynski marked this conversation as resolved.

<!-- OS Constants ==================================================== -->
<PropertyGroup>
<!-- @TODO: Move to directory.build.props? -->
Expand Down Expand Up @@ -60,6 +66,26 @@
<!-- included into the build. -->
<EmbeddedResource Include="Resources/ILLink.Substitutions.xml"
Condition="'$(NormalizedTargetOs)' == 'windows_nt' AND '$(TargetFramework)' != 'net462'" />

<!-- Base strings in English -->
<EmbeddedResource Update="Resources\Strings.resx">
<LogicalName>Microsoft.Data.SqlClient.Resources.Strings.resources</LogicalName>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
<CustomToolNamespace>System</CustomToolNamespace>
</EmbeddedResource>

<!-- Include all strings that have been translated -->
<EmbeddedResource Update="Resources\Strings.*.resx">
<LogicalName>Microsoft.Data.SqlClient.Resources.%(Filename).resources</LogicalName>
</EmbeddedResource>

<!-- Strings designer that depends on the resx -->
<Compile Update="Resources\Strings.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Strings.resx</DependentUpon>
</Compile>
</ItemGroup>

<!-- References ====================================================== -->
Expand Down
Comment thread
cheenamalhotra marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>Microsoft.Data.SqlClient.TestCommon</AssemblyName>
<RootNamespace>Microsoft.Data.SqlClient.TestCommon</RootNamespace>
Comment thread
benrr101 marked this conversation as resolved.
<Nullable>enable</Nullable>
</PropertyGroup>
Comment thread
benrr101 marked this conversation as resolved.

<!-- Embedded resources and content files =========================== -->
<ItemGroup>
<ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>xunit.runner.json</TargetPath>
</ContentWithTargetPath>
</ItemGroup>

<!-- References ====================================================== -->
<!-- Test target reference -->
<ItemGroup>
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj" />
</ItemGroup>

<!-- References for netfx -->
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Security.KeyVault.Keys" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<PackageReference Include="xunit" />
</ItemGroup>

<!-- References for netcore -->
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
<PackageReference Include="Azure.Identity" />
<PackageReference Include="Azure.Security.KeyVault.Keys" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
<PackageReference Include="xunit" />
</ItemGroup>
Comment thread
cheenamalhotra marked this conversation as resolved.
</Project>
Comment thread
paulmedynski marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,71 +1,81 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- @TODO: Use full assembly name here -->
<AssemblyName>UnitTests</AssemblyName>
Comment thread
paulmedynski marked this conversation as resolved.
Comment thread
benrr101 marked this conversation as resolved.
<TargetGroup Condition="$(TargetFramework.StartsWith('net4'))">netfx</TargetGroup>
<TargetGroup Condition="$(TargetGroup) == ''">netcoreapp</TargetGroup>
<RuntimeIdentifier Condition="'$(TargetGroup)'=='netfx'">win</RuntimeIdentifier>
<IntermediateOutputPath>$(ObjFolder)$(Configuration).$(Platform).$(AssemblyName)</IntermediateOutputPath>
<OutputPath>$(BinFolder)$(Configuration).$(Platform).$(AssemblyName)</OutputPath>
<RootNamespace />
<IsTestProject>true</IsTestProject>
<Nullable>enable</Nullable>
</PropertyGroup>
<!-- Common references -->

<!-- Embedded resources and content files =========================== -->
<ItemGroup>
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Condition="$(TargetGroup) == 'netfx'">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.console">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<EmbeddedResource Update="Resources.resx">
<LogicalName>Microsoft.Data.SqlClient.UnitTests.Resources.resources</LogicalName>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<ContentWithTargetPath Include="$(TestsPath)tools/Microsoft.Data.SqlClient.TestUtilities/xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>xunit.runner.json</TargetPath>
</ContentWithTargetPath>
</ItemGroup>

<!-- References ====================================================== -->
<!-- Test target reference -->
<ItemGroup>
<ProjectReference Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj" />
</ItemGroup>

<!-- References for netframework -->
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<Reference Include="System.Transactions" />

<PackageReference Include="Microsoft.Data.SqlClient.SNI" />
Comment thread
cheenamalhotra marked this conversation as resolved.
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
<PackageReference Include="Microsoft.SqlServer.Server" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.console"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
<PackageReference Include="xunit.runner.visualstudio"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />

<ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" />
<ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" />
<ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" />
<ProjectReference Include="$(TestsPath)Common\Common.csproj" />
</ItemGroup>
<!-- .NET Framework references -->
<ItemGroup Condition="$(TargetGroup) == 'netfx'">
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" />
<ProjectReference Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" />
<Reference Include="System.Transactions" />
<ProjectReference Include="$(TestsPath)Common\Microsoft.Data.SqlClient.TestCommon.csproj" />
Comment thread
benrr101 marked this conversation as resolved.
</ItemGroup>
<!-- .NET references -->
<ItemGroup Condition="'$(TargetGroup)'=='netcoreapp'">
<ProjectReference Include="$(NetCoreSource)src\Microsoft.Data.SqlClient.csproj" />
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Condition="'$(TargetGroup)'=='netfx'" Include="$(BinFolder)$(Configuration).AnyCPU\Microsoft.Data.SqlClient\netfx\$(TargetFramework)\*SNI*.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>%(Filename)%(Extension)</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>xunit.runner.json</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
<!-- Resources -->
<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>

<EmbeddedResource Update="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<!-- References for netcore -->
<ItemGroup Condition="'$(TargetFramework)' != 'net462'">
<PackageReference Include="Microsoft.Data.SqlClient.SNI.runtime" />
Comment thread
cheenamalhotra marked this conversation as resolved.
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Microsoft.SqlServer.Server" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
<PackageReference Include="xunit" />
Comment thread
cheenamalhotra marked this conversation as resolved.
<PackageReference Include="xunit.runner.console"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />
<PackageReference Include="xunit.runner.visualstudio"
IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive"
PrivateAssets="all" />

<ProjectReference Include="$(TestsPath)tools\TDS\TDS.Servers\TDS.Servers.csproj" />
<ProjectReference Include="$(TestsPath)tools\TDS\TDS.EndPoint\TDS.EndPoint.csproj" />
<ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj" />
<ProjectReference Include="$(TestsPath)Common\Microsoft.Data.SqlClient.TestCommon.csproj" />
Comment thread
cheenamalhotra marked this conversation as resolved.
</ItemGroup>
Comment thread
paulmedynski marked this conversation as resolved.
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ public void NetworkTimeout_ShouldFail()
using SqlConnection connection = new(builder.ConnectionString);

// Act
var e = Assert.Throws<SqlException>(() => connection.Open());
Action action = () => connection.Open();

// Assert
Assert.Contains("Connection Timeout Expired", e.Message);
SqlException exception = Assert.Throws<SqlException>(action);
Assert.Contains("Connection Timeout Expired", exception.Message);

Assert.Equal(ConnectionState.Closed, connection.State);
Assert.Equal(1, server.PreLoginCount);
Assert.Equal(0, failoverServer.PreLoginCount);
Expand Down Expand Up @@ -214,7 +216,7 @@ public void NetworkDelay_ShouldConnectToPrimary()
SqlConnectionStringBuilder builder = new()
{
DataSource = "localhost," + server.EndPoint.Port,
InitialCatalog = "master",// Required for failover partner to work
InitialCatalog = "master", // Required for failover partner to work
ConnectTimeout = 5,
Encrypt = false,
MultiSubnetFailover = false,
Expand All @@ -223,15 +225,9 @@ public void NetworkDelay_ShouldConnectToPrimary()
#endif
};
using SqlConnection connection = new(builder.ConnectionString);
try
{
// Act
connection.Open();
}
catch (Exception e)
{
Assert.Fail(e.Message);
}

// Act
connection.Open();
Comment thread
cheenamalhotra marked this conversation as resolved.

// Assert
// On the first connection attempt, no failover partner information is available,
Expand Down Expand Up @@ -274,15 +270,10 @@ public void NetworkError_WithUserProvidedPartner_RetryDisabled_ShouldConnectToFa
Encrypt = false,
};
using SqlConnection connection = new(builder.ConnectionString);
try
{
// Act
connection.Open();
}
catch (Exception e)
{
Assert.Fail(e.Message);
}

// Act
connection.Open();


Comment thread
cheenamalhotra marked this conversation as resolved.
// Assert
// On the first connection attempt, failover partner information is available in the connection string,
Expand Down
Loading