Skip to content
This repository has been archived by the owner on Mar 9, 2024. It is now read-only.

replace MSTest with XUnit.net #32

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
32 changes: 16 additions & 16 deletions MoneroClient.sln
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoneroClient", "MoneroClient.csproj", "{5B3EAD04-7CB8-4A2B-91BA-9F0EEC39EC4F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{752CD2CE-2A17-41AC-8931-F3F7B347013C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MoneroClientTests", "Tests\MoneroClientTests\MoneroClientTests.csproj", "{D1332264-3814-4FAB-91B2-0F0399FB1EC3}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MoneroClient.UnitTests", "Tests\MoneroClient.UnitTests\MoneroClient.UnitTests.csproj", "{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -31,24 +31,24 @@ Global
{5B3EAD04-7CB8-4A2B-91BA-9F0EEC39EC4F}.Release|x64.Build.0 = Release|x64
{5B3EAD04-7CB8-4A2B-91BA-9F0EEC39EC4F}.Release|x86.ActiveCfg = Release|x86
{5B3EAD04-7CB8-4A2B-91BA-9F0EEC39EC4F}.Release|x86.Build.0 = Release|x86
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Debug|x64.ActiveCfg = Debug|Any CPU
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Debug|x64.Build.0 = Debug|Any CPU
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Debug|x86.ActiveCfg = Debug|x84
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Debug|x86.Build.0 = Debug|x84
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Release|Any CPU.Build.0 = Release|Any CPU
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Release|x64.ActiveCfg = Release|x64
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Release|x64.Build.0 = Release|x64
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Release|x86.ActiveCfg = Release|Any CPU
{D1332264-3814-4FAB-91B2-0F0399FB1EC3}.Release|x86.Build.0 = Release|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Debug|x64.ActiveCfg = Debug|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Debug|x64.Build.0 = Debug|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Debug|x86.ActiveCfg = Debug|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Debug|x86.Build.0 = Debug|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Release|Any CPU.Build.0 = Release|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Release|x64.ActiveCfg = Release|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Release|x64.Build.0 = Release|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Release|x86.ActiveCfg = Release|Any CPU
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{D1332264-3814-4FAB-91B2-0F0399FB1EC3} = {752CD2CE-2A17-41AC-8931-F3F7B347013C}
{DB7ECA37-87DA-4000-97E8-71FCDA6C7456} = {752CD2CE-2A17-41AC-8931-F3F7B347013C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88A52E0B-BDE4-4CB3-96A0-3D38793952CA}
Expand Down
26 changes: 26 additions & 0 deletions Tests/MoneroClient.UnitTests/MoneroClient.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>

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

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\MoneroClient.csproj" />
</ItemGroup>

</Project>
71 changes: 71 additions & 0 deletions Tests/MoneroClient.UnitTests/Utilities/PriceUtilitiesTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using Monero.Client.Utilities;
using System;
using Xunit;

namespace MoneroClient.UnitTests.Utilities
{
public class PriceUtilitiesTests
{
[Theory]
[InlineData(0, 0)]
[InlineData(0.000000000001, 1)]
[InlineData(1, 1000000000000)]
[InlineData(0.5, 500000000000)]
[InlineData(1.5, 1500000000000)]
public void MoneroToPiconero_ValidMoneroAmounts_ReturnsCorrectPiconero(decimal monero, ulong expectedPiconero)
{
var piconero = PriceUtilities.MoneroToPiconero(monero);
Assert.Equal(expectedPiconero, piconero);
}

[Fact]
public void MoneroToPiconero_OneThirteenthAMonero_Throws()
{
decimal monero = 0.0000000000001M;
Action GetPiconero = () => PriceUtilities.MoneroToPiconero(monero);
Assert.Throws<InvalidOperationException>(GetPiconero);
}

[Fact]
public void MoneroToPiconero_MaxMonero_Throws()
{
decimal monero = decimal.MaxValue;
Action GetPiconero = () => PriceUtilities.MoneroToPiconero(monero);
Assert.Throws<OverflowException>(GetPiconero);
}

[Fact]
public void MoneroToPiconero_NegativeMonero_Throws()
{
decimal monero = -1;
Action GetPiconero = () => PriceUtilities.MoneroToPiconero(monero);
Assert.Throws<InvalidOperationException>(() => GetPiconero());
}

[Fact]
public void MoneroToPiconero_MoreThan12DecimalPlaces_Throws()
{
decimal monero = 1.000000000000123M;
Action GetPiconero = () => PriceUtilities.MoneroToPiconero(monero);
Assert.Throws<InvalidOperationException>(GetPiconero);
}

[Theory]
[InlineData(10, 0.000000000010)]
[InlineData(1, 0.000000000001)]
[InlineData(0, 0)]
public void PiconeroToMonero_ValidPiconeroAmounts_ReturnsCorrectMonero(ulong piconero, decimal expectedMonero)
{
var monero = PriceUtilities.PiconeroToMonero(piconero);
Assert.Equal(expectedMonero, monero);
}

[Fact]
public void PiconeroToMonero_MaxPiconero_DoesNotThrow()
{
ulong piconero = ulong.MaxValue;
_ = PriceUtilities.PiconeroToMonero(piconero);
// Does not throw.
}
}
}
21 changes: 0 additions & 21 deletions Tests/MoneroClientTests/MoneroClientTests.csproj

This file was deleted.

116 changes: 0 additions & 116 deletions Tests/MoneroClientTests/PriceUtilitiesTests.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Utilities/PriceUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Runtime.CompilerServices;
using System.Text;

[assembly: InternalsVisibleTo("Monero.Client.Tests")]
[assembly: InternalsVisibleTo("MoneroClient.UnitTests")]
namespace Monero.Client.Utilities
{

Expand Down