Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test | Removing internal build of XunitExtensions and using the nuget #2033

Merged
merged 30 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from 26 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
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,7 @@ dotnet_code_quality.ca1802.api_surface = private, internal

[*.cs]
dotnet_code_quality.CA2100.excluded_type_names_with_derived_types = Microsoft.Data.SqlClient.ManualTesting.Tests.*
dotnet_diagnostic.xUnit1031.severity=none
dotnet_diagnostic.xUnit1030.severity=none


2 changes: 0 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<FunctionalTests Include="**/tools/TDS/TDS/TDS.csproj" />
<FunctionalTests Include="**/tools/TDS/TDS.EndPoint/TDS.EndPoint.csproj" />
<FunctionalTests Include="**/tools/TDS/TDS.Servers/TDS.Servers.csproj" />
<FunctionalTests Include="**/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj" />
<FunctionalTests Include="**/tools/CoreFx.Private.TestUtilities/CoreFx.Private.TestUtilities.csproj" />
<FunctionalTests Include="**/ManualTests/SQL/UdtTest/UDTs/Address/Address.csproj" />
<FunctionalTests Include="**/FunctionalTests/Microsoft.Data.SqlClient.Tests.csproj" />
Expand All @@ -64,7 +63,6 @@
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Circle/Circle.csproj" />
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Shapes/Shapes.csproj" />
<ManualTests Include="**/ManualTests/SQL/UdtTest/UDTs/Utf8String/Utf8String.csproj" />
<ManualTests Include="**/tools/Microsoft.DotNet.XUnitExtensions/Microsoft.DotNet.XUnitExtensions.csproj" />
<ManualTests Include="**/tools/Microsoft.Data.SqlClient.TestUtilities/Microsoft.Data.SqlClient.TestUtilities.csproj"/>
<ManualTests Include="**/tools/CoreFx.Private.TestUtilities/CoreFx.Private.TestUtilities.csproj" />
<ManualTests Include="**/CustomConfigurableRetryLogic/CustomRetryLogicProvider.csproj" />
Expand Down Expand Up @@ -177,14 +175,14 @@
<Target Name="RunTests" DependsOnTargets="RunFunctionalTests;RunManualTests"/>
<Target Name="RunFunctionalTests">
<!-- Windows -->
<Exec ConsoleToMsBuild="true" Command="$(DotnetPath)dotnet test &quot;@(FunctionalTestsProj)&quot; -p:Configuration=$(Configuration) -p:Target$(TFGroup)Version=$(TF) --no-build -v n --collect &quot;Code coverage&quot; -p:TestSet=$(TestSet) --results-directory $(ResultsDirectory) -p:TestTargetOS=Windows$(TargetGroup) --filter &quot;category!=non$(TargetGroup)tests&amp;category!=failing&amp;category!=nonwindowstests&quot; &quot;--logger:trx;LogFilePrefix=Functional-Windows$(TargetGroup)-$(TestSet)&quot;" Condition="'$(IsEnabledWindows)' == 'true'"/>

Check failure on line 178 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win 2022 ARM64 Azure SQL net462,AnyCPU,true,2,netstandard2.1)

build.proj#L178

build.proj(178,5): Error MSB3073: The command "dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" -p:Configuration=Release -p:TargetnetfxVersion=net462 --no-build -v n --collect "Code coverage" -p:TestSet=2 --results-directory TestResults -p:TestTargetOS=Windowsnetfx --filter "category!=nonnetfxtests&category!=failing&category!=nonwindowstests" "--logger:trx;LogFilePrefix=Functional-Windowsnetfx-2"" exited with code 1.

Check failure on line 178 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win 11 Azure SQL net7.0,AnyCPU,true,3,netstandard2.1)

build.proj#L178

build.proj(178,5): Error MSB3073: The command "dotnet test "src\Microsoft.Data.SqlClient\tests\FunctionalTests\Microsoft.Data.SqlClient.Tests.csproj" -p:Configuration=Release -p:TargetnetcoreVersion=net7.0 --no-build -v n --collect "Code coverage" -p:TestSet=3 --results-directory TestResults -p:TestTargetOS=Windowsnetcoreapp --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" "--logger:trx;LogFilePrefix=Functional-Windowsnetcoreapp-3"" exited with code 1.
<!-- Unix -->
<Exec ConsoleToMsBuild="true" Command="$(DotnetPath)dotnet test &quot;@(FunctionalTestsProj)&quot; -p:Configuration=$(Configuration) -p:TargetNetCoreVersion=$(TF) --no-build -v n -p:TestSet=$(TestSet) --results-directory $(ResultsDirectory) -p:TestTargetOS=Unixnetcoreapp --collect &quot;Code coverage&quot; --filter &quot;category!=nonnetcoreapptests&amp;category!=failing&amp;category!=nonlinuxtests&amp;category!=nonuaptests&quot; &quot;--logger:trx;LogFilePrefix=Functional-Unixnetcoreapp-$(TestSet)&quot;" Condition="'$(IsEnabledWindows)' != 'true'"/>
</Target>

<Target Name="RunManualTests">
<!-- Windows -->
<Exec ConsoleToMsBuild="true" Command="$(DotnetPath)dotnet test &quot;@(ManualTestsProj)&quot; -p:Configuration=$(Configuration) -p:Target$(TFGroup)Version=$(TF) --no-build -l &quot;console;verbosity=normal&quot; --collect &quot;Code coverage&quot; -p:TestSet=$(TestSet) --results-directory $(ResultsDirectory) -p:TestTargetOS=Windows$(TargetGroup) --filter &quot;category!=non$(TargetGroup)tests&amp;category!=failing&amp;category!=nonwindowstests&quot; &quot;--logger:trx;LogFilePrefix=Manual-Windows$(TargetGroup)-$(TestSet)&quot;" Condition="'$(IsEnabledWindows)' == 'true'"/>

Check failure on line 185 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win 2022 Azure SQL net7.0,AnyCPU,true,3,netstandard2.1)

build.proj#L185

build.proj(185,5): Error MSB3073: The command "dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Configuration=Release -p:TargetnetcoreVersion=net7.0 --no-build -l "console;verbosity=normal" --collect "Code coverage" -p:TestSet=3 --results-directory TestResults -p:TestTargetOS=Windowsnetcoreapp --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" "--logger:trx;LogFilePrefix=Manual-Windowsnetcoreapp-3"" exited with code 1.

Check failure on line 185 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win 11 Azure SQL net7.0,AnyCPU,true,1,netstandard2.1)

build.proj#L185

build.proj(185,5): Error MSB3073: The command "dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Configuration=Release -p:TargetnetcoreVersion=net7.0 --no-build -l "console;verbosity=normal" --collect "Code coverage" -p:TestSet=1 --results-directory TestResults -p:TestTargetOS=Windowsnetcoreapp --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" "--logger:trx;LogFilePrefix=Manual-Windowsnetcoreapp-1"" exited with code 1.

Check failure on line 185 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient (Win 11 Azure SQL net7.0,AnyCPU,false,2,netstandard2.1)

build.proj#L185

build.proj(185,5): Error MSB3073: The command "dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Configuration=Release -p:TargetnetcoreVersion=net7.0 --no-build -l "console;verbosity=normal" --collect "Code coverage" -p:TestSet=2 --results-directory TestResults -p:TestTargetOS=Windowsnetcoreapp --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" "--logger:trx;LogFilePrefix=Manual-Windowsnetcoreapp-2"" exited with code 1.

Check failure on line 185 in build.proj

View check run for this annotation

Azure Pipelines / CI-SqlClient

build.proj#L185

build.proj(185,5): Error MSB3073: The command "dotnet test "src\Microsoft.Data.SqlClient\tests\ManualTests\Microsoft.Data.SqlClient.ManualTesting.Tests.csproj" -p:Configuration=Release -p:TargetnetcoreVersion=net7.0 --no-build -l "console;verbosity=normal" --collect "Code coverage" -p:TestSet=3 --results-directory TestResults -p:TestTargetOS=Windowsnetcoreapp --filter "category!=nonnetcoreapptests&category!=failing&category!=nonwindowstests" "--logger:trx;LogFilePrefix=Manual-Windowsnetcoreapp-3"" exited with code 1.
<!-- Unix -->
<Exec ConsoleToMsBuild="true" Command="$(DotnetPath)dotnet test &quot;@(ManualTestsProj)&quot; -p:Configuration=$(Configuration) -p:TargetNetCoreVersion=$(TF) --no-build -l &quot;console;verbosity=normal&quot; --collect &quot;Code coverage&quot; -p:TestSet=$(TestSet) --results-directory $(ResultsDirectory) -p:TestTargetOS=Unixnetcoreapp --filter &quot;category!=nonnetcoreapptests&amp;category!=failing&amp;category!=nonlinuxtests&amp;category!=nonuaptests&quot; &quot;--logger:trx;LogFilePrefix=Manual-Unixnetcoreapp-$(TestSet)&quot;" Condition="'$(IsEnabledWindows)' != 'true'"/>
</Target>
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.Data.SqlClient.sln
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Data.SqlClient.Al
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "add-ons", "add-ons", "{C9726AED-D6A3-4AAC-BA04-92DD1F079594}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.DotNet.XUnitExtensions", "Microsoft.Data.SqlClient\tests\tools\Microsoft.DotNet.XUnitExtensions\Microsoft.DotNet.XUnitExtensions.csproj", "{FDA6971D-9F57-4DA4-B10A-261C91684CFC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{ED952CF7-84DF-437A-B066-F516E9BE1C2C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "snippets", "snippets", "{71F356DC-DFA3-4163-8BFE-D268722CE189}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public void TestAeadEncryptionReversal(string dataType, object data, Utility.CCo
break;

default:
Assert.True(false, "unexpected data type.");
Assert.Fail("unexpected data type.");
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.

using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Transactions;
using Xunit;
Expand All @@ -11,7 +12,7 @@ namespace Microsoft.Data.SqlClient.Tests
{
public class AmbientTransactionFailureTest
{

private static readonly bool s_isNotArmProcess = TestUtility.IsNotArmProcess;
private static readonly string s_servername = Guid.NewGuid().ToString();
private static readonly string s_connectionStringWithEnlistAsDefault = $"Data Source={s_servername}; Integrated Security=true; Connect Timeout=1;";
private static readonly string s_connectionStringWithEnlistOff = $"Data Source={s_servername}; Integrated Security=true; Connect Timeout=1;Enlist=False";
Expand Down Expand Up @@ -73,7 +74,7 @@ public class AmbientTransactionFailureTest
new object[] { EnlistConnectionInTransaction, s_connectionStringWithEnlistOff }
};

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArmProcess))] // https://github.com/dotnet/corefx/issues/21598
[ConditionalTheory(nameof(s_isNotArmProcess))] // https://github.com/dotnet/corefx/issues/21598
[MemberData(nameof(ExceptionTestDataForSqlException))]
public void TestSqlException(Action<string> connectAction, string connectionString)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
// Licensed to the .NET Foundation under one or more agreements.
// 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 System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient.Tests;
using Xunit;
using Xunit.Sdk;

namespace System
{
public static class AssertExtensions
{
private static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal);
private static bool IsFullFramework => TestUtility.IsFullFramework;

public static void Throws<T>(Action action, string message)
where T : Exception
Expand All @@ -35,7 +36,7 @@ public static void Throws<T>(string netCoreParamName, string netFxParamName, Act
IsFullFramework ?
netFxParamName : netCoreParamName;

if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
if (!TestUtility.NetNative)
Assert.Equal(expectedParamName, exception.ParamName);
}

Expand All @@ -54,7 +55,7 @@ public static void Throws<T>(string netCoreParamName, string netFxParamName, Fun
IsFullFramework ?
netFxParamName : netCoreParamName;

if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
if (!TestUtility.NetNative)
Assert.Equal(expectedParamName, exception.ParamName);
}

Expand All @@ -63,7 +64,7 @@ public static T Throws<T>(string paramName, Action action)
{
T exception = Assert.Throws<T>(action);

if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
if (!TestUtility.NetNative)
Assert.Equal(paramName, exception.ParamName);

return exception;
Expand All @@ -82,7 +83,7 @@ public static T Throws<T>(string paramName, Func<object> testCode)
{
T exception = Assert.Throws<T>(testCode);

if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
if (!TestUtility.NetNative)
Assert.Equal(paramName, exception.ParamName);

return exception;
Expand All @@ -93,7 +94,7 @@ public static async Task<T> ThrowsAsync<T>(string paramName, Func<Task> testCode
{
T exception = await Assert.ThrowsAsync<T>(testCode);

if (!RuntimeInformation.FrameworkDescription.StartsWith(".NET Native", StringComparison.Ordinal))
if (!TestUtility.NetNative)
Assert.Equal(paramName, exception.ParamName);

return exception;
Expand Down Expand Up @@ -298,24 +299,5 @@ public static void GreaterThanOrEqualTo<T>(T actual, T greaterThanOrEqualTo, str
throw new XunitException(AddOptionalUserMessage($"Expected: {actual} to be greater than or equal to {greaterThanOrEqualTo}", userMessage));
}

/// <summary>
/// Validates that the actual byte array is equal to the expected byte array. XUnit only displays the first 5 values
/// of each collection if the test fails. This doesn't display at what point or how the equality assertion failed.
/// </summary>
/// <param name="expected">The byte array that <paramref name="actual"/> should be equal to.</param>
/// <param name="actual"></param>
public static void Equal(byte[] expected, byte[] actual)
{
try
{
Assert.Equal(expected, actual);
}
catch (AssertActualExpectedException)
{
string expectedString = string.Join(", ", expected);
string actualString = string.Join(", ", actual);
throw new AssertActualExpectedException(expectedString, actualString, null);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// 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 System;
JRahnama marked this conversation as resolved.
Show resolved Hide resolved
using System.Runtime.InteropServices;

namespace Microsoft.Data.SqlClient.Tests
{
public static class TestUtility
{
public static readonly bool IsNotArmProcess = RuntimeInformation.ProcessArchitecture != Architecture.Arm;
public static bool IsFullFramework => RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework");
public static bool NetNative => RuntimeInformation.FrameworkDescription.StartsWith(".NET Native");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
<Compile Include="AlwaysEncryptedTests\SqlConnectionShould.cs" />
<Compile Include="AlwaysEncryptedTests\TestFixtures.cs" />
<Compile Include="AlwaysEncryptedTests\Utility.cs" />
<Compile Include="AssertExtensions.cs" />
<Compile Include="DataCommon\AssemblyResourceManager.cs" />
<Compile Include="DataCommon\SystemDataResourceManager.cs" />
<Compile Include="DataCommon\TestUtility.cs" />
<Compile Include="LocalizationTest.cs" />
<Compile Include="MultipartIdentifierTests.cs" />
<Compile Include="SqlClientLoggerTest.cs" />
Expand Down Expand Up @@ -66,6 +68,25 @@
<Compile Include="SqlHelperTest.cs" />
<Compile Include="..\..\src\Microsoft\Data\Common\MultipartIdentifier.cs" />
</ItemGroup>
<!-- XUnit and XUnit extensions -->
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="$(MicrosoftNETFrameworkReferenceAssembliesVersion)" Condition="$(TargetGroup) == 'netfx'">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Condition="$(TargetGroup) == 'netfx'" Include="System.Runtime.InteropServices.RuntimeInformation" Version="$(SystemRuntimeInteropServicesRuntimeInformationVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.console" Version="$(XunitVersion)">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.utility" Version="$(XunitVersion)" />
<PackageReference Include="Microsoft.DotNet.XUnitExtensions" Version="$(MicrosoftDotNetXUnitExtensionsVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftExtensionsHosting)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkVersion)" />
Expand All @@ -92,21 +113,21 @@
<ProjectReference Include="$(TestsPath)tools\TDS\TDS\TDS.csproj">
<Name>TDS</Name>
</ProjectReference>
<ProjectReference Include="$(TestsPath)tools\Microsoft.DotNet.XUnitExtensions\Microsoft.DotNet.XUnitExtensions.csproj">
<Name>Microsoft.DotNet.XUnitExtensions</Name>
</ProjectReference>
<ProjectReference Condition="!$(ReferenceType.Contains('NetStandard'))" Include="$(AddOnsPath)AzureKeyVaultProvider\Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj" />
<ProjectReference Condition="'$(TargetGroup)'=='netcoreapp' AND $(ReferenceType)=='Project'" Include="$(NetCoreSource)src\Microsoft.Data.SqlClient.csproj" />
<ProjectReference Condition="'$(TargetGroup)'=='netfx' AND $(ReferenceType)=='Project'" Include="$(NetFxSource)src\Microsoft.Data.SqlClient.csproj" />
<ProjectReference Condition="$(ReferenceType.Contains('NetStandard'))" Include="$(TestsPath)NSLibrary\Microsoft.Data.SqlClient.NSLibrary.csproj" />
<ProjectReference Condition="!$(ReferenceType.Contains('Package'))" Include="$(SqlServerSource)Microsoft.SqlServer.Server.csproj" />
<PackageReference Condition="$(ReferenceType.Contains('Package'))" Include="Microsoft.Data.SqlClient" Version="$(TestMicrosoftDataSqlClientVersion)" />
<!-- .NET Core 3.1.2 known issue; It should be added manually! -->
<!-- https://github.com/dotnet/core/blob/main/release-notes/3.1/3.1-known-issues.md#net-core-312-sdk-31102-sdk -->
<PackageReference Condition="'$(TargetFramework)'=='net6.0' AND $(ReferenceType)=='Package'" Include="System.Security.Cryptography.Cng" Version="$(SystemSecurityCryptographyCngVersion)" />
</ItemGroup>
<ItemGroup>
<None Condition="'$(TargetGroup)'=='netfx' AND $(ReferenceType)=='Project'" Include="$(BinFolder)$(Configuration).AnyCPU\Microsoft.Data.SqlClient\netfx\**\*SNI*.dll" CopyToOutputDirectory="PreserveNewest" />
<PackageReference Condition="$(ReferenceType.Contains('Package'))" Include="Microsoft.Identity.Client" Version="$(MicrosoftIdentityClientVersion)" />
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="..\tools\Microsoft.Data.SqlClient.TestUtilities\xunit.runner.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<TargetPath>xunit.runner.json</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System;
using System.Collections;
using System.Diagnostics;

using Xunit;

namespace Microsoft.Data.SqlClient.Tests
Expand Down Expand Up @@ -420,7 +419,7 @@ public void InsertAndClear_BehavesAsExpected()
Assert.Same(item3, list[2]);

list.Clear();
Assert.Equal(0, list.Count);
Assert.Empty(list);

list.Add(item1);
list.Add(item3);
Expand All @@ -435,7 +434,7 @@ public void InsertAndClear_BehavesAsExpected()
Assert.Same(item3, list[2]);

list.Clear();
Assert.Equal(0, list.Count);
Assert.Empty(list);
}

[Fact]
Expand Down Expand Up @@ -463,11 +462,11 @@ public void Remove_BehavesAsExpected()
IList list = CreateCollection(item1, item2);

list.Remove(item1);
Assert.Equal(1, list.Count);
Assert.Single(list);
Assert.Same(item2, list[0]);

list.Remove(item2);
Assert.Equal(0, list.Count);
Assert.Empty(list);

AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(item2));
AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(new SqlBulkCopyColumnMapping(2, 2)));
Expand Down Expand Up @@ -504,11 +503,11 @@ public void RemoveAt_BehavesAsExpected()
Assert.Same(item3, list[1]);

list.RemoveAt(1);
Assert.Equal(1, list.Count);
Assert.Single(list);
Assert.Same(item2, list[0]);

list.RemoveAt(0);
Assert.Equal(0, list.Count);
Assert.Empty(list);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ public void InsertAndClear_BehavesAsExpected()
Assert.Same(item3, list[2]);

list.Clear();
Assert.Equal(0, list.Count);
Assert.Empty(list);

list.Add(item1);
list.Add(item3);
Expand All @@ -410,7 +410,7 @@ public void InsertAndClear_BehavesAsExpected()
Assert.Same(item3, list[2]);

list.Clear();
Assert.Equal(0, list.Count);
Assert.Empty(list);
}

[Fact]
Expand All @@ -434,11 +434,11 @@ public void Remove_BehavesAsExpected()
IList list = CreateCollection(item1, item2);

list.Remove(item1);
Assert.Equal(1, list.Count);
Assert.Single(list);
Assert.Same(item2, list[0]);

list.Remove(item2);
Assert.Equal(0, list.Count);
Assert.Empty(list);

AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(item2));
AssertExtensions.Throws<ArgumentException>(null, () => list.Remove(new SqlBulkCopyColumnOrderHint("column4", SortOrder.Ascending)));
Expand Down Expand Up @@ -473,11 +473,11 @@ public void RemoveAt_BehavesAsExpected()
Assert.Same(item2, list[0]);
Assert.Same(item3, list[1]);
list.RemoveAt(1);
Assert.Equal(1, list.Count);
Assert.Single(list);
Assert.Same(item2, list[0]);

list.RemoveAt(0);
Assert.Equal(0, list.Count);
Assert.Empty(list);
}

[Fact]
Expand Down
Loading
Loading