From cb2002b6191e7d346f381d5de887c63145063afc Mon Sep 17 00:00:00 2001 From: "Valeriano A.R." Date: Sun, 21 Jan 2024 18:11:22 +0100 Subject: [PATCH] Migrate to Sdk projects. * BasicBlockChain.Core. * BasicBlockChain.Core.Tests. * Migrate MSTests to XUnit. --- .../BasicBlockChain.Core.Tests.csproj | 115 +++--------------- ...BlockChain_Tests.cs => BlockChainTests.cs} | 26 ++-- .../Properties/AssemblyInfo.cs | 1 - .../BasicBlockChain.Core.csproj | 57 ++------- BasicBlockChain.Core/Block.cs | 4 +- BasicBlockChain.Core/BlockChain.cs | 8 +- .../Properties/AssemblyInfo.cs | 3 +- BasicBlockChain.Core/Transaction.cs | 4 +- 8 files changed, 40 insertions(+), 178 deletions(-) rename BasicBlockChain.Core.Tests/{BlockChain_Tests.cs => BlockChainTests.cs} (79%) diff --git a/BasicBlockChain.Core.Tests/BasicBlockChain.Core.Tests.csproj b/BasicBlockChain.Core.Tests/BasicBlockChain.Core.Tests.csproj index a776eee..9a6632a 100644 --- a/BasicBlockChain.Core.Tests/BasicBlockChain.Core.Tests.csproj +++ b/BasicBlockChain.Core.Tests/BasicBlockChain.Core.Tests.csproj @@ -1,106 +1,23 @@ - - - + + - Debug - AnyCPU - {F3B0EB12-6F98-4AFE-8405-BD687A04E8D0} - Library - Properties + net7.0 + enable BasicBlockChain.Core.Tests - BasicBlockChain.Core.Tests - v4.8 - 512 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 10.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages - False - UnitTest - - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + - - ..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - - - ..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + - - - - - - - - + - - + - - - - - - {919BC116-C8FC-4B65-B742-226B38437C48} - BasicBlockChain.Core - - - - - - - False - - - False - - - False - - - False - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - \ No newline at end of file + + diff --git a/BasicBlockChain.Core.Tests/BlockChain_Tests.cs b/BasicBlockChain.Core.Tests/BlockChainTests.cs similarity index 79% rename from BasicBlockChain.Core.Tests/BlockChain_Tests.cs rename to BasicBlockChain.Core.Tests/BlockChainTests.cs index f168ff8..99514b5 100644 --- a/BasicBlockChain.Core.Tests/BlockChain_Tests.cs +++ b/BasicBlockChain.Core.Tests/BlockChainTests.cs @@ -1,10 +1,8 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Xunit; namespace BasicBlockChain.Core.Tests { - [TestClass()] - public class BlockChain_Tests + public class BlockChainTests { #region Test Data @@ -24,27 +22,27 @@ namespace BasicBlockChain.Core.Tests #region Verify - [TestMethod()] + [Fact] public void Verify__Null() { BlockChain nullCoin = new BlockChain(); bool result = nullCoin.Verify(); - Assert.AreEqual(true, result); + Assert.True(result); } - [TestMethod()] + [Fact] public void Verify__Valid() { BlockChain nullCoin = GenerateTestData(); bool result = nullCoin.Verify(); - Assert.AreEqual(true, result); + Assert.True(result); } - [TestMethod()] + [Fact] public void Verify__Tampered() { BlockChain nullCoin = GenerateTestData(); @@ -52,14 +50,14 @@ namespace BasicBlockChain.Core.Tests bool result = nullCoin.Verify(); - Assert.AreEqual(false, result); + Assert.False(result); } #endregion Verify #region GetMicroCoinBalance - [TestMethod()] + [Fact] public void GetMicroCoinBalance__Test() { BlockChain nullCoin = GenerateTestData(); @@ -69,9 +67,9 @@ namespace BasicBlockChain.Core.Tests long balanceKable = nullCoin.GetMicroCoinBalance("Kable"); long expectedBlananceKable = nullCoin.Reward * 3; - Assert.AreEqual(0, balanceVAR); - Assert.AreEqual(0, balanceNAM); - Assert.AreEqual(expectedBlananceKable, balanceKable); + Assert.Equal(0, balanceVAR); + Assert.Equal(0, balanceNAM); + Assert.Equal(expectedBlananceKable, balanceKable); } #endregion GetMicroCoinBalance diff --git a/BasicBlockChain.Core.Tests/Properties/AssemblyInfo.cs b/BasicBlockChain.Core.Tests/Properties/AssemblyInfo.cs index 881e6bc..3c1e4fc 100644 --- a/BasicBlockChain.Core.Tests/Properties/AssemblyInfo.cs +++ b/BasicBlockChain.Core.Tests/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following diff --git a/BasicBlockChain.Core/BasicBlockChain.Core.csproj b/BasicBlockChain.Core/BasicBlockChain.Core.csproj index 4749761..b0e934f 100644 --- a/BasicBlockChain.Core/BasicBlockChain.Core.csproj +++ b/BasicBlockChain.Core/BasicBlockChain.Core.csproj @@ -1,56 +1,13 @@ - - - + + - Debug - AnyCPU - {919BC116-C8FC-4B65-B742-226B38437C48} - Library - Properties + net7.0 + enable BasicBlockChain.Core - BasicBlockChain.Core - v4.8 - 512 - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + - - - - - - - - - - ..\packages\VAR.Json.1.2.0.1065\lib\net461\VAR.Json.dll - + - - - - - - - - - - \ No newline at end of file diff --git a/BasicBlockChain.Core/Block.cs b/BasicBlockChain.Core/Block.cs index 0bc8d2e..8d7f100 100644 --- a/BasicBlockChain.Core/Block.cs +++ b/BasicBlockChain.Core/Block.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Security.Cryptography; +using System.Security.Cryptography; using System.Text; using VAR.Json; diff --git a/BasicBlockChain.Core/BlockChain.cs b/BasicBlockChain.Core/BlockChain.cs index a4b0303..641d38b 100644 --- a/BasicBlockChain.Core/BlockChain.cs +++ b/BasicBlockChain.Core/BlockChain.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace BasicBlockChain.Core +namespace BasicBlockChain.Core { public class BlockChain { @@ -11,7 +7,7 @@ namespace BasicBlockChain.Core public int Difficulty { get; set; } = 2; public int Reward { get; set; } = 1_000_000; - private List _users = null; + private List _users; public List Users { diff --git a/BasicBlockChain.Core/Properties/AssemblyInfo.cs b/BasicBlockChain.Core/Properties/AssemblyInfo.cs index 7245c9d..29617bc 100644 --- a/BasicBlockChain.Core/Properties/AssemblyInfo.cs +++ b/BasicBlockChain.Core/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -10,7 +9,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BasicBlockChain.Core")] -[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyCopyright("Copyright © VAR 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/BasicBlockChain.Core/Transaction.cs b/BasicBlockChain.Core/Transaction.cs index 8e1beae..3ae3db4 100644 --- a/BasicBlockChain.Core/Transaction.cs +++ b/BasicBlockChain.Core/Transaction.cs @@ -1,6 +1,4 @@ -using System; - -namespace BasicBlockChain.Core +namespace BasicBlockChain.Core { public class Transaction {