Skip to content

Commit 559894d

Browse files
committed
Updated test project
+semver:major
1 parent 384d9f1 commit 559894d

File tree

3 files changed

+18
-32
lines changed

3 files changed

+18
-32
lines changed

src/SqlAlias/SqlAlias.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
11
using System;
2-
#if !NET40
32
using Microsoft.Data.SqlClient;
43
using System.Runtime.InteropServices;
54

6-
#endif
7-
85
namespace SqlAlias
96
{
107
public static class Aliases
118
{
12-
#if NET40
13-
public static string Map(string connectionString) => connectionString;
14-
internal static bool ShouldSubstitute() => false;
15-
#else
169
public static string Map(string connectionString)
1710
{
1811
if (!ShouldSubstitute())
@@ -37,7 +30,5 @@ public static string Map(string connectionString)
3730
internal static bool ShouldSubstitute()
3831
=> RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
3932
!RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework");
40-
41-
#endif
4233
}
4334
}

src/Tests/AllTheTests.cs

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
using NUnit.Framework;
22
using SqlAlias;
33

4-
namespace Tests
4+
namespace Tests;
5+
6+
public class AllTheTests
57
{
6-
public class AllTheTests
8+
[Test]
9+
public void CorrectlyDetectsWhetherSubstitutionIsRequired()
710
{
8-
[Test]
9-
public void CorrectlyDetectsWhetherSubstitutionIsRequired()
10-
{
11-
var result = Aliases.ShouldSubstitute();
12-
#if NET40 || NET45 || NET472
13-
Assert.IsFalse(result);
14-
#else
15-
Assert.IsTrue(result);
16-
#endif
17-
}
11+
var result = Aliases.ShouldSubstitute();
12+
Assert.That(result, Is.True);
13+
}
1814

19-
[Test]
20-
public void MapReturnsTheSameConnectionStringIfThereIsNoSubstitute()
21-
{
22-
const string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword";
23-
var result = Aliases.Map(connectionString);
24-
Assert.AreEqual(connectionString, result);
25-
}
15+
[Test]
16+
public void MapReturnsTheSameConnectionStringIfThereIsNoSubstitute()
17+
{
18+
const string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword";
19+
var result = Aliases.Map(connectionString);
20+
Assert.That(result, Is.EqualTo(connectionString));
2621
}
2722
}

src/Tests/Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net40;net45;net472;netcoreapp3.1;net5.0</TargetFrameworks>
4+
<TargetFramework>net8.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
1010
<ProjectReference Include="..\SqlAlias\SqlAlias.csproj" />
11-
<PackageReference Include="NUnit" Version="3.13.1" />
12-
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
13-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
11+
<PackageReference Include="NUnit" Version="4.1.0" />
12+
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
1414
</ItemGroup>
1515

1616
</Project>

0 commit comments

Comments
 (0)