Skip to content

Commit cac3b1a

Browse files
authored
Common MDS | Cleanup Manual Tests (#3932)
* Rename manual test project csproj * Cleanup ManualTests project file, make conditional files conditional * Comments from *last* PR * Fix tests that had names that conflict with helper methods. Not sure why this is just now a problem, but ok, I'll fix it. * Move test data files, fix references * Can't reference the new test common project yet... * SqlMetaData resolution in common MDS project Rewrite VerifyGetCommand in adapter test to no longer use reflection/dynamic invocation * Fix test Common project references in ManualTests project * Remove conditional compilation where possible. * Remove OS constants from manual tests project
1 parent db47359 commit cac3b1a

24 files changed

Lines changed: 488 additions & 522 deletions

build.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
<ManualTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
9292
<ManualTests Include="**/tools/TDS/TDS.Servers/TDS.Servers.csproj" />
9393
<ManualTests Include="**/CustomConfigurableRetryLogic/CustomRetryLogicProvider.csproj" />
94-
<ManualTests Include="**/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" />
95-
<ManualTestsProj Include="**/ManualTests/Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" />
94+
<ManualTests Include="**/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj" />
95+
<ManualTestsProj Include="**/ManualTests/Microsoft.Data.SqlClient.ManualTests.csproj" />
9696
</ItemGroup>
9797

9898
<!-- Top Level Build targets -->

src/Microsoft.Data.SqlClient.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Address", "Microsoft.Data.S
2727
{407890AC-9876-4FEF-A6F1-F36A876BAADE} = {407890AC-9876-4FEF-A6F1-F36A876BAADE}
2828
EndProjectSection
2929
EndProject
30-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.ManualTesting.Tests", "Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj", "{45DB5F86-7AE3-45C6-870D-F9357B66BDB5}"
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.ManualTests", "Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTests.csproj", "{45DB5F86-7AE3-45C6-870D-F9357B66BDB5}"
3131
ProjectSection(ProjectDependencies) = postProject
3232
{37431336-5307-4184-9356-C4B7E47DC714} = {37431336-5307-4184-9356-C4B7E47DC714}
3333
EndProjectSection

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,10 @@
10491049
<Link>Resources\ILLink.Substitutions.xml</Link>
10501050
</EmbeddedResource>
10511051

1052+
<!-- Used by SqlMetaDataFactory to construct its DataSet -->
10521053
<EmbeddedResource Include="$(CommonSourceRoot)Resources\Microsoft.Data.SqlClient.SqlMetaData.xml">
10531054
<Link>Resources\Microsoft.Data.SqlCLient.SqlMetaData.xml</Link>
1054-
<LogicalName>Microsoft.Data.SqlClient.SqlMetaData.xml</LogicalName> <!-- @TODO: How necessary is this? -->
1055+
<LogicalName>Microsoft.Data.SqlClient.SqlMetaData.xml</LogicalName>
10551056
</EmbeddedResource>
10561057

10571058
<!-- Base strings in English -->

src/Microsoft.Data.SqlClient/src/Microsoft.Data.SqlClient.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,15 @@
8181
<!-- the app context switch in their csproj. This file only applies to netcore on windows. -->
8282
<!-- This file does not support pre-processor directives, so it must be conditionally -->
8383
<!-- included into the build. -->
84-
<EmbeddedResource Include="Resources/ILLink.Substitutions.xml"
84+
<EmbeddedResource Include="Resources\ILLink.Substitutions.xml"
8585
Condition="'$(NormalizedTargetOs)' == 'windows_nt' AND '$(TargetFramework)' != 'net462'" />
8686

87+
<!-- Used by SqlMetaDataFactory to construct its DataSet -->
88+
<EmbeddedResource Include="Resources\Microsoft.Data.SqlClient.SqlMetaData.xml">
89+
<Link>Resources\Microsoft.Data.SqlCLient.SqlMetaData.xml</Link>
90+
<LogicalName>Microsoft.Data.SqlClient.SqlMetaData.xml</LogicalName>
91+
</EmbeddedResource>
92+
8793
<!-- Base strings in English -->
8894
<EmbeddedResource Update="Resources\Strings.resx">
8995
<LogicalName>Microsoft.Data.SqlClient.Resources.Strings.resources</LogicalName>

src/Microsoft.Data.SqlClient/tests/FunctionalTests/Microsoft.Data.SqlClient.FunctionalTests.csproj

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,31 @@
77
</PropertyGroup>
88

99
<!-- Links to internal project files ================================= -->
10-
<!-- @TODO: These should be removed -->
1110
<ItemGroup>
11+
<!-- @TODO: These should be removed -->
12+
<!-- These files are links to internal classes in the MDS project that a collection of -->
13+
<!-- tests directly test. Since InternalsVisibleTo doesn't work with ManualTests (not sure -->
14+
<!-- why, to be honest), the only way to test them within this project is to directly -->
15+
<!-- compile them as part of this project. This is not ideal in the slightest, and they -->
16+
<!-- should ideally be UnitTests if they need to access internals. But detangling these -->
17+
<!-- tests is far beyond the scope of the common project, so it is left as a TODO for now. -->
1218
<Compile Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft/Data/Common/MultipartIdentifier.cs" />
1319
<Compile Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Packet.cs" />
1420
<Compile Include="$(RepoRoot)src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.Multiplexer.cs" />
1521
</ItemGroup>
1622

1723
<!-- Embedded resources and content files =========================== -->
1824
<ItemGroup>
19-
<!-- This file sets some configuration setting that only apply to netfx. It cannot #if -->
20-
<!-- included into the project, so it must be included via a condition attribute. -->
25+
<!-- This file sets some configuration setting that only apply to netfx. It cannot be #if -->
26+
<!-- included into the project, so it must be included via a condition attribute. -->
2127
<None Update="app.config" Condition="'$(TargetFramework)' == 'net462'">
2228
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2329
</None>
2430

25-
<ContentWithTargetPath Include="$(TestsPath)tools/Microsoft.Data.SqlClient.TestUtilities/xunit.runner.json">
31+
<Content Include="$(TestsPath)tools/Microsoft.Data.SqlClient.TestUtilities/xunit.runner.json">
2632
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2733
<TargetPath>xunit.runner.json</TargetPath>
28-
</ContentWithTargetPath>
34+
</Content>
2935
</ItemGroup>
3036

3137
<!-- References ====================================================== -->

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/CspProviderExt.cs

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,18 @@
55
using System.Collections.Generic;
66
using System.IO;
77
using System.Linq;
8-
using System.Security.Cryptography.X509Certificates;
9-
using Xunit;
108
using System.Security.Cryptography;
9+
using System.Security.Cryptography.X509Certificates;
1110
using Microsoft.Data.SqlClient.Tests.Common.Fixtures;
1211
using Microsoft.Win32;
13-
14-
#if NET
15-
using System.Runtime.Versioning;
16-
#endif
12+
using Xunit;
1713

1814
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted
1915
{
2016
/// <summary>
2117
/// Always Encrypted public CspProvider Manual tests.
22-
/// TODO: These tests are marked as Windows only for now but should be run for all platforms once the Master Key is accessible to this app from Azure Key Vault.
2318
/// </summary>
24-
#if !NETFRAMEWORK
25-
[SupportedOSPlatform("windows")]
26-
#endif
19+
// TODO: These tests are marked as Windows only for now but should be run for all platforms once the Master Key is accessible to this app from Azure Key Vault.
2720
[PlatformSpecific(TestPlatforms.Windows)]
2821
public class CspProviderExt
2922
{

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.cs renamed to src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/DateOnlyReadTests.netcore.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
// This file must be conditionally included because it will not compile on netfx
6+
#if NET
7+
58
using System;
69
using System.Collections;
710
using System.Collections.Generic;
@@ -91,3 +94,5 @@ public IEnumerator<object[]> GetEnumerator()
9194
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
9295
}
9396
}
97+
98+
#endif

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/Setup/CspProviderColumnMasterKey.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System;
65
using System.Security.Cryptography.X509Certificates;
76

87
namespace Microsoft.Data.SqlClient.ManualTesting.Tests.AlwaysEncrypted.Setup
@@ -14,18 +13,19 @@ public class CspProviderColumnMasterKey : ColumnMasterKey
1413
public string Thumbprint { get; }
1514
public override string KeyPath { get; }
1615

17-
public CspProviderColumnMasterKey(string name, string certificateThumbprint) : base(name)
16+
public CspProviderColumnMasterKey(string name, string certificateThumbprint)
17+
: base(name)
1818
{
1919
KeyStoreProviderName = @"MSSQL_CERTIFICATE_STORE";
2020
Thumbprint = certificateThumbprint;
2121
KeyPath = string.Concat(CertificateStoreLocation.ToString(), "/", CertificateStoreName.ToString(), "/", Thumbprint);
2222
}
2323

24-
public CspProviderColumnMasterKey(string name, string providerName, string cspKeyPath) : base(name)
24+
public CspProviderColumnMasterKey(string name, string providerName, string cspKeyPath)
25+
: base(name)
2526
{
2627
KeyStoreProviderName = providerName;
2728
KeyPath = cspKeyPath;
2829
}
29-
3030
}
3131
}

src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SQLSetupStrategyCspProvider.cs renamed to src/Microsoft.Data.SqlClient/tests/ManualTests/AlwaysEncrypted/TestFixtures/SqlSetupStrategyCspProvider.cs

File renamed without changes.

src/Microsoft.Data.SqlClient/tests/ManualTests/DDBasics/DDDataTypesTest/DDDataTypesTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static void XmlTest()
3939
SqlCommand cmd2 = new SqlCommand(insertParamStr, conn);
4040

4141
cmd2.Parameters.Add("@x", SqlDbType.Xml);
42-
XmlReader xr = XmlReader.Create("data.xml");
42+
XmlReader xr = XmlReader.Create("DDDataTypesTest_Data.xml");
4343
cmd2.Parameters[0].Value = new SqlXml(xr);
4444
cmd2.ExecuteNonQuery();
4545

0 commit comments

Comments
 (0)