1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-09 22:55:42 +00:00

Multi-target X10D.Tests

This commit is contained in:
Oliver Booth 2022-05-07 23:16:06 +01:00
parent 39ccf1f198
commit ed2920f8a0
No known key found for this signature in database
GPG Key ID: 32A00B35503AF634
10 changed files with 29 additions and 8 deletions

View File

@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>netstandard2.1;net6.0</TargetFrameworks>
<LangVersion>10.0</LangVersion>
<IsPackable>false</IsPackable>
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>

View File

@ -67,10 +67,11 @@ public class CollectionTests
Assert.IsTrue(IsDisposed = true);
}
public ValueTask DisposeAsync()
#pragma warning disable CS1998
public async ValueTask DisposeAsync()
#pragma warning restore CS1998
{
Assert.IsTrue(IsDisposed = true);
return ValueTask.CompletedTask;
}
}
}

View File

@ -126,10 +126,11 @@ public class EnumerableTests
Assert.IsTrue(IsDisposed = true);
}
public ValueTask DisposeAsync()
#pragma warning disable CS1998
public async ValueTask DisposeAsync()
#pragma warning restore CS1998
{
Assert.IsTrue(IsDisposed = true);
return ValueTask.CompletedTask;
}
}
}

View File

@ -7,6 +7,7 @@ namespace X10D.Tests.Math;
[TestClass]
public class DecimalTests
{
#if NETCOREAPP3_0_OR_GREATER
[TestMethod]
public void ComplexSqrt_ShouldBeCorrect_GivenReal()
{
@ -25,6 +26,7 @@ public class DecimalTests
Assert.AreEqual(new Complex(0, 3.0), (-9.0m).ComplexSqrt());
Assert.AreEqual(new Complex(0, 4.0), (-16.0m).ComplexSqrt());
}
#endif
[TestMethod]
public void IsEven_ShouldBeFalse_GivenOddNumber()

View File

@ -29,6 +29,7 @@ public class DoubleTests
Assert.AreEqual(12.0, 0.20943951023931953.RadiansToDegrees(), 1e-6);
}
#if NETCOREAPP3_0_OR_GREATER
[TestMethod]
public void ComplexSqrt_ShouldBeCorrect_GivenReal()
{
@ -60,6 +61,7 @@ public class DoubleTests
{
Assert.AreEqual(Complex.NaN, double.NaN.ComplexSqrt());
}
#endif
[TestMethod]
public void IsEven_ShouldBeFalse_GivenOddNumber()

View File

@ -29,6 +29,7 @@ public class SingleTests
Assert.AreEqual(12.0f, 0.20943952f.RadiansToDegrees(), 1e-6f);
}
#if NETCOREAPP3_0_OR_GREATER
[TestMethod]
public void ComplexSqrt_ShouldBeCorrect_GivenReal()
{
@ -60,6 +61,7 @@ public class SingleTests
{
Assert.AreEqual(Complex.NaN, float.NaN.ComplexSqrt());
}
#endif
[TestMethod]
public void IsEven_ShouldBeFalse_GivenOddNumber()

View File

@ -6,6 +6,7 @@ namespace X10D.Tests.Text;
[TestClass]
public class CoreTests
{
#if NET5_0_OR_GREATER
[TestMethod]
public void ToJsonShouldNotBeEmpty()
{
@ -23,4 +24,5 @@ public class CoreTests
CollectionAssert.AreEqual(source, target);
CollectionAssert.AreEquivalent(source, target);
}
#endif
}

View File

@ -1,4 +1,5 @@
using System.Text;
#if NETCOREAPP3_0_OR_GREATER
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using X10D.Text;
@ -37,3 +38,4 @@ public class RuneTests
Assert.ThrowsException<ArgumentOutOfRangeException>(() => new Rune('a').Repeat(-1));
}
}
#endif

View File

@ -1,5 +1,7 @@
using System.Text;
using System.Text;
#if NET5_0_OR_GREATER
using System.Text.Json.Serialization;
#endif
using Microsoft.VisualStudio.TestTools.UnitTesting;
using X10D.Text;
@ -149,6 +151,7 @@ public class StringTests
Assert.ThrowsException<ArgumentException>(() => " ".EnumParse<DayOfWeek>());
}
#if NET5_0_OR_GREATER
[TestMethod]
public void FromJson_ShouldDeserializeCorrectly_GivenJsonString()
{
@ -162,6 +165,7 @@ public class StringTests
Assert.AreEqual(2, target.Values[1]);
Assert.AreEqual(3, target.Values[2]);
}
#endif
[TestMethod]
public void GetBytes_ShouldReturnUtf8Bytes_GivenHelloWorld()
@ -441,9 +445,11 @@ public class StringTests
Assert.AreEqual(alternative, ((string?)null).WithWhiteSpaceAlternative(alternative));
}
#if NET5_0_OR_GREATER
private struct SampleStructure
{
[JsonPropertyName("values")]
public int[] Values { get; set; }
}
#endif
}

View File

@ -1,4 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
#if NET5_0_OR_GREATER
using Microsoft.VisualStudio.TestTools.UnitTesting;
using X10D.Time;
namespace X10D.Tests.Time;
@ -51,3 +52,4 @@ public class DoubleTests
Assert.IsTrue((_negativeOne).Weeks() < TimeSpan.Zero);
}
}
#endif