diff --git a/tests/Neo.SmartContract.Framework.UnitTests/Services/SequencePointInserterTest.cs b/tests/Neo.SmartContract.Framework.UnitTests/Services/SequencePointInserterTest.cs index 17e9819d3..76b3cfb0a 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/Services/SequencePointInserterTest.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/Services/SequencePointInserterTest.cs @@ -1,5 +1,4 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; -using Neo.SmartContract.Template.UnitTests.templates; using Neo.SmartContract.Testing; using Neo.SmartContract.Testing.TestingStandards; using Neo.VM; diff --git a/tests/Neo.SmartContract.Framework.UnitTests/TestCleanup.cs b/tests/Neo.SmartContract.Framework.UnitTests/TestCleanup.cs index 35f848bae..c9c1a3023 100644 --- a/tests/Neo.SmartContract.Framework.UnitTests/TestCleanup.cs +++ b/tests/Neo.SmartContract.Framework.UnitTests/TestCleanup.cs @@ -10,11 +10,12 @@ using System.Reflection; using System.Text.RegularExpressions; -namespace Neo.SmartContract.Template.UnitTests.templates +namespace Neo.SmartContract.Framework.UnitTests { [TestClass] - public partial class TestCleanup + public class TestCleanup { + private static readonly Regex WhiteSpaceRegex = new("\\s"); internal static readonly Dictionary DebugInfos = new(); /// @@ -95,7 +96,7 @@ private static NeoDebugInfo CreateArtifact(string typeName, CompilationContext c var artifact = manifest.GetArtifactsSource(typeName, nef, generateProperties: true); string writtenArtifact = File.Exists(artifactsPath) ? File.ReadAllText(artifactsPath) : ""; - if (writtenArtifact == "" || WhiteSpaceRegex().Replace(artifact, "") != WhiteSpaceRegex().Replace(writtenArtifact, "")) + if (writtenArtifact == "" || WhiteSpaceRegex.Replace(artifact, "") != WhiteSpaceRegex.Replace(writtenArtifact, "")) { // Uncomment to overwrite the artifact file File.WriteAllText(artifactsPath, artifact); @@ -171,8 +172,5 @@ public static void EnsureCoverage() Assert.IsTrue(coverage.CoveredLinesPercentage >= RequiredCoverage, $"Coverage is less than {RequiredCoverage:P2}"); } - - [GeneratedRegex(@"\s")] - private static partial Regex WhiteSpaceRegex(); } } diff --git a/tests/Neo.SmartContract.Template.UnitTests/templates/TestCleanup.cs b/tests/Neo.SmartContract.Template.UnitTests/templates/TestCleanup.cs index 8e0b1f24a..87b8e3531 100644 --- a/tests/Neo.SmartContract.Template.UnitTests/templates/TestCleanup.cs +++ b/tests/Neo.SmartContract.Template.UnitTests/templates/TestCleanup.cs @@ -12,8 +12,10 @@ namespace Neo.SmartContract.Template.UnitTests.templates { [TestClass] - public partial class TestCleanup + public class TestCleanup { + private static readonly Regex WhiteSpaceRegex = new("\\s"); + private static NeoDebugInfo? DebugInfo_NEP17; private static NeoDebugInfo? DebugInfo_Oracle; private static NeoDebugInfo? DebugInfo_Ownable; @@ -67,9 +69,6 @@ public void EnsureArtifactsUpToDate() Path.Combine(artifactsPath, "neocontractowner/TestingArtifacts/OwnableTemplate.artifacts.cs")); } - [GeneratedRegex(@"\s")] - private static partial Regex WhiteSpaceRegex(); - private static (string artifact, NeoDebugInfo debugInfo) CreateArtifact(CompilationContext context, string rootDebug, string artifactsPath) { (var nef, var manifest, var debugInfo) = context.CreateResults(rootDebug); @@ -77,7 +76,7 @@ private static (string artifact, NeoDebugInfo debugInfo) CreateArtifact(Compi var artifact = manifest.GetArtifactsSource(typeof(T).Name, nef, generateProperties: true); string writtenArtifact = File.Exists(artifactsPath) ? File.ReadAllText(artifactsPath) : ""; - if (writtenArtifact == "" || WhiteSpaceRegex().Replace(artifact, "") != WhiteSpaceRegex().Replace(writtenArtifact, "")) + if (writtenArtifact == "" || WhiteSpaceRegex.Replace(artifact, "") != WhiteSpaceRegex.Replace(writtenArtifact, "")) { // Uncomment to overwrite the artifact file File.WriteAllText(artifactsPath, artifact); diff --git a/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs b/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs index a672e6343..69ade6d46 100644 --- a/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs +++ b/tests/Neo.SmartContract.Testing.UnitTests/Coverage/CoverageDataTests.cs @@ -7,10 +7,9 @@ namespace Neo.SmartContract.Testing.UnitTests.Coverage { [TestClass] - public partial class CoverageDataTests + public class CoverageDataTests { - [GeneratedRegex(@"\s")] - private static partial Regex WhiteSpaceRegex(); + private static readonly Regex WhiteSpaceRegex = new("\\s"); [TestMethod] public void TestDump() @@ -21,7 +20,7 @@ public void TestDump() Assert.AreEqual(100_000_000, engine.Native.NEO.TotalSupply); - Assert.AreEqual(WhiteSpaceRegex().Replace(@" + Assert.AreEqual(WhiteSpaceRegex.Replace(@" NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [5.00 % - 100.00 %] ┌-───────────────────────────────-┬-────────-┬-────────-┐ │ Method │ Line │ Branch │ @@ -47,16 +46,16 @@ NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [5.00 % - 100.00 %] │ unregisterCandidate(pubkey) │ 0.00 % │ 100.00 % │ │ vote(account,voteTo) │ 0.00 % │ 100.00 % │ └-───────────────────────────────-┴-────────-┴-────────-┘ -", ""), WhiteSpaceRegex().Replace(engine.GetCoverage(engine.Native.NEO)?.Dump(), "")); +", ""), WhiteSpaceRegex.Replace(engine.GetCoverage(engine.Native.NEO)?.Dump(), "")); - Assert.AreEqual(WhiteSpaceRegex().Replace(@" + Assert.AreEqual(WhiteSpaceRegex.Replace(@" NeoToken [0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5] [5.00 % - 100.00 %] ┌-─────────────-┬-────────-┬-────────-┐ │ Method │ Line │ Branch │ ├-─────────────-┼-────────-┼-────────-┤ │ totalSupply() │ 100.00 % │ 100.00 % │ └-─────────────-┴-────────-┴-────────-┘ -", ""), WhiteSpaceRegex().Replace((engine.Native.NEO.GetCoverage(o => o.TotalSupply) as CoveredMethod)?.Dump(), "")); +", ""), WhiteSpaceRegex.Replace((engine.Native.NEO.GetCoverage(o => o.TotalSupply) as CoveredMethod)?.Dump(), "")); } [TestMethod]