Migrate to Sdk projects.
* BasicBlockChain.Core. * BasicBlockChain.Core.Tests. * Migrate MSTests to XUnit.
This commit is contained in:
@@ -1,106 +1,23 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ProjectGuid>{F3B0EB12-6F98-4AFE-8405-BD687A04E8D0}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>BasicBlockChain.Core.Tests</RootNamespace>
|
<RootNamespace>BasicBlockChain.Core.Tests</RootNamespace>
|
||||||
<AssemblyName>BasicBlockChain.Core.Tests</AssemblyName>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
|
||||||
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
|
|
||||||
<IsCodedUITest>False</IsCodedUITest>
|
|
||||||
<TestProjectType>UnitTest</TestProjectType>
|
|
||||||
<TargetFrameworkProfile />
|
|
||||||
<NuGetPackageImportStamp>
|
|
||||||
</NuGetPackageImportStamp>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||||
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
|
<PackageReference Include="xunit" Version="2.6.3" />
|
||||||
</Reference>
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5">
|
||||||
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
<HintPath>..\packages\MSTest.TestFramework.2.1.1\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
</Reference>
|
</PackageReference>
|
||||||
<Reference Include="System" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Choose>
|
|
||||||
<When Condition="('$(VisualStudioVersion)' == '10.0' or '$(VisualStudioVersion)' == '') and '$(TargetFrameworkVersion)' == 'v3.5'">
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
|
|
||||||
</ItemGroup>
|
|
||||||
</When>
|
|
||||||
<Otherwise />
|
|
||||||
</Choose>
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BlockChain_Tests.cs" />
|
<ProjectReference Include="..\BasicBlockChain.Core\BasicBlockChain.Core.csproj" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="packages.config" />
|
</Project>
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\BasicBlockChain.Core\BasicBlockChain.Core.csproj">
|
|
||||||
<Project>{919BC116-C8FC-4B65-B742-226B38437C48}</Project>
|
|
||||||
<Name>BasicBlockChain.Core</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Choose>
|
|
||||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="Microsoft.VisualStudio.QualityTools.CodedUITestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITest.Extension, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Microsoft.VisualStudio.TestTools.UITesting, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
|
||||||
<Private>False</Private>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
</When>
|
|
||||||
</Choose>
|
|
||||||
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
|
||||||
<PropertyGroup>
|
|
||||||
<ErrorText>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}.</ErrorText>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.props'))" />
|
|
||||||
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets'))" />
|
|
||||||
</Target>
|
|
||||||
<Import Project="..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.1.1\build\net45\MSTest.TestAdapter.targets')" />
|
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
|
||||||
<Target Name="BeforeBuild">
|
|
||||||
</Target>
|
|
||||||
<Target Name="AfterBuild">
|
|
||||||
</Target>
|
|
||||||
-->
|
|
||||||
</Project>
|
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
using System;
|
using Xunit;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace BasicBlockChain.Core.Tests
|
namespace BasicBlockChain.Core.Tests
|
||||||
{
|
{
|
||||||
[TestClass()]
|
public class BlockChainTests
|
||||||
public class BlockChain_Tests
|
|
||||||
{
|
{
|
||||||
#region Test Data
|
#region Test Data
|
||||||
|
|
||||||
@@ -24,27 +22,27 @@ namespace BasicBlockChain.Core.Tests
|
|||||||
|
|
||||||
#region Verify
|
#region Verify
|
||||||
|
|
||||||
[TestMethod()]
|
[Fact]
|
||||||
public void Verify__Null()
|
public void Verify__Null()
|
||||||
{
|
{
|
||||||
BlockChain nullCoin = new BlockChain();
|
BlockChain nullCoin = new BlockChain();
|
||||||
|
|
||||||
bool result = nullCoin.Verify();
|
bool result = nullCoin.Verify();
|
||||||
|
|
||||||
Assert.AreEqual(true, result);
|
Assert.True(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod()]
|
[Fact]
|
||||||
public void Verify__Valid()
|
public void Verify__Valid()
|
||||||
{
|
{
|
||||||
BlockChain nullCoin = GenerateTestData();
|
BlockChain nullCoin = GenerateTestData();
|
||||||
|
|
||||||
bool result = nullCoin.Verify();
|
bool result = nullCoin.Verify();
|
||||||
|
|
||||||
Assert.AreEqual(true, result);
|
Assert.True(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod()]
|
[Fact]
|
||||||
public void Verify__Tampered()
|
public void Verify__Tampered()
|
||||||
{
|
{
|
||||||
BlockChain nullCoin = GenerateTestData();
|
BlockChain nullCoin = GenerateTestData();
|
||||||
@@ -52,14 +50,14 @@ namespace BasicBlockChain.Core.Tests
|
|||||||
|
|
||||||
bool result = nullCoin.Verify();
|
bool result = nullCoin.Verify();
|
||||||
|
|
||||||
Assert.AreEqual(false, result);
|
Assert.False(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Verify
|
#endregion Verify
|
||||||
|
|
||||||
#region GetMicroCoinBalance
|
#region GetMicroCoinBalance
|
||||||
|
|
||||||
[TestMethod()]
|
[Fact]
|
||||||
public void GetMicroCoinBalance__Test()
|
public void GetMicroCoinBalance__Test()
|
||||||
{
|
{
|
||||||
BlockChain nullCoin = GenerateTestData();
|
BlockChain nullCoin = GenerateTestData();
|
||||||
@@ -69,9 +67,9 @@ namespace BasicBlockChain.Core.Tests
|
|||||||
long balanceKable = nullCoin.GetMicroCoinBalance("Kable");
|
long balanceKable = nullCoin.GetMicroCoinBalance("Kable");
|
||||||
long expectedBlananceKable = nullCoin.Reward * 3;
|
long expectedBlananceKable = nullCoin.Reward * 3;
|
||||||
|
|
||||||
Assert.AreEqual(0, balanceVAR);
|
Assert.Equal(0, balanceVAR);
|
||||||
Assert.AreEqual(0, balanceNAM);
|
Assert.Equal(0, balanceNAM);
|
||||||
Assert.AreEqual(expectedBlananceKable, balanceKable);
|
Assert.Equal(expectedBlananceKable, balanceKable);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion GetMicroCoinBalance
|
#endregion GetMicroCoinBalance
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|||||||
@@ -1,56 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<ProjectGuid>{919BC116-C8FC-4B65-B742-226B38437C48}</ProjectGuid>
|
|
||||||
<OutputType>Library</OutputType>
|
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
|
||||||
<RootNamespace>BasicBlockChain.Core</RootNamespace>
|
<RootNamespace>BasicBlockChain.Core</RootNamespace>
|
||||||
<AssemblyName>BasicBlockChain.Core</AssemblyName>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<Deterministic>true</Deterministic>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<PackageReference Include="VAR.Json" Version="1.2.2"/>
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
<Reference Include="VAR.Json, Version=1.2.0.1065, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\VAR.Json.1.2.0.1065\lib\net461\VAR.Json.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<Compile Include="Block.cs" />
|
|
||||||
<Compile Include="BlockChain.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
<Compile Include="Transaction.cs" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="packages.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
using System.Security.Cryptography;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using VAR.Json;
|
using VAR.Json;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace BasicBlockChain.Core
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace BasicBlockChain.Core
|
|
||||||
{
|
{
|
||||||
public class BlockChain
|
public class BlockChain
|
||||||
{
|
{
|
||||||
@@ -11,7 +7,7 @@ namespace BasicBlockChain.Core
|
|||||||
public int Difficulty { get; set; } = 2;
|
public int Difficulty { get; set; } = 2;
|
||||||
public int Reward { get; set; } = 1_000_000;
|
public int Reward { get; set; } = 1_000_000;
|
||||||
|
|
||||||
private List<string> _users = null;
|
private List<string> _users;
|
||||||
|
|
||||||
public List<string> Users
|
public List<string> Users
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
@@ -10,7 +9,7 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("BasicBlockChain.Core")]
|
[assembly: AssemblyProduct("BasicBlockChain.Core")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2020")]
|
[assembly: AssemblyCopyright("Copyright © VAR 2020")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
namespace BasicBlockChain.Core
|
||||||
|
|
||||||
namespace BasicBlockChain.Core
|
|
||||||
{
|
{
|
||||||
public class Transaction
|
public class Transaction
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user