Skip to content

Commit

Permalink
Updated test project
Browse files Browse the repository at this point in the history
+semver:major
  • Loading branch information
droyad committed May 14, 2024
1 parent 384d9f1 commit 559894d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 32 deletions.
9 changes: 0 additions & 9 deletions src/SqlAlias/SqlAlias.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
using System;
#if !NET40
using Microsoft.Data.SqlClient;
using System.Runtime.InteropServices;

#endif

namespace SqlAlias
{
public static class Aliases
{
#if NET40
public static string Map(string connectionString) => connectionString;
internal static bool ShouldSubstitute() => false;
#else
public static string Map(string connectionString)
{
if (!ShouldSubstitute())
Expand All @@ -37,7 +30,5 @@ public static string Map(string connectionString)
internal static bool ShouldSubstitute()
=> RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
!RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework");

#endif
}
}
33 changes: 14 additions & 19 deletions src/Tests/AllTheTests.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
using NUnit.Framework;
using SqlAlias;

namespace Tests
namespace Tests;

public class AllTheTests
{
public class AllTheTests
[Test]
public void CorrectlyDetectsWhetherSubstitutionIsRequired()
{
[Test]
public void CorrectlyDetectsWhetherSubstitutionIsRequired()
{
var result = Aliases.ShouldSubstitute();
#if NET40 || NET45 || NET472
Assert.IsFalse(result);
#else
Assert.IsTrue(result);
#endif
}
var result = Aliases.ShouldSubstitute();
Assert.That(result, Is.True);
}

[Test]
public void MapReturnsTheSameConnectionStringIfThereIsNoSubstitute()
{
const string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword";
var result = Aliases.Map(connectionString);
Assert.AreEqual(connectionString, result);
}
[Test]
public void MapReturnsTheSameConnectionStringIfThereIsNoSubstitute()
{
const string connectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword";
var result = Aliases.Map(connectionString);
Assert.That(result, Is.EqualTo(connectionString));
}
}
8 changes: 4 additions & 4 deletions src/Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net40;net45;net472;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SqlAlias\SqlAlias.csproj" />
<PackageReference Include="NUnit" Version="3.13.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
</ItemGroup>

</Project>

0 comments on commit 559894d

Please sign in to comment.