diff --git a/tst/CTA.Rules.Test/CTA.Rules.Test.csproj b/tst/CTA.Rules.Test/CTA.Rules.Test.csproj index 1e5c4ca9..741b4e76 100644 --- a/tst/CTA.Rules.Test/CTA.Rules.Test.csproj +++ b/tst/CTA.Rules.Test/CTA.Rules.Test.csproj @@ -41,6 +41,12 @@ PreserveNewest + + + Always + + + Always PreserveNewest diff --git a/tst/CTA.Rules.Test/RuleContributionTests.cs b/tst/CTA.Rules.Test/RuleContributionTests.cs index f22bd533..382f8f83 100644 --- a/tst/CTA.Rules.Test/RuleContributionTests.cs +++ b/tst/CTA.Rules.Test/RuleContributionTests.cs @@ -1,8 +1,6 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using NUnit.Framework; namespace CTA.Rules.Test; @@ -15,18 +13,17 @@ namespace CTA.Rules.Test; [TestFixture] class RuleContributionTests : AwsRulesBaseTest { + private const string RuleContributionsSolutionFileName = "RuleContributions.sln"; + private const string RuleContributionsProjectFileName = "RuleContributions.csproj"; private string _tempDir = ""; - private string _downloadLocation; private Dictionary _resultsDict; [OneTimeSetUp] public void Setup() { _tempDir = SetupTests.TempDir; - _downloadLocation = SetupTests.DownloadLocation; - var solutionName = "RuleContributions.sln"; - var solutionPath = CopySolutionFolderToTemp(solutionName, _tempDir); + var solutionPath = CopySolutionFolderToTemp(RuleContributionsSolutionFileName, _tempDir); var net31Results = AnalyzeSolution(solutionPath, TargetFramework.DotnetCoreApp31); var net50Results = AnalyzeSolution(solutionPath, TargetFramework.Dotnet5); var net60Results = AnalyzeSolution(solutionPath, TargetFramework.Dotnet6); @@ -38,24 +35,29 @@ public void Setup() {TargetFramework.Dotnet6, net60Results} }; } - + [TestCase(TargetFramework.DotnetCoreApp31)] [TestCase(TargetFramework.Dotnet5)] [TestCase(TargetFramework.Dotnet6)] - public void TestProjectFilePortingResults(string version) + public void Porting_With_All_Contributed_Rules_Results_In_Zero_Build_Errors(string version) + { + var solutionPortingResult = _resultsDict[version]; + CollectionAssert.IsEmpty(solutionPortingResult.SolutionRunResult.BuildErrors); + } + + [TestCase(TargetFramework.DotnetCoreApp31)] + [TestCase(TargetFramework.Dotnet5)] + [TestCase(TargetFramework.Dotnet6)] + public void DynamicQuery_Package_Is_Added_And_Namespaces_Are_Replaced(string version) { - var projectFileName = "RuleContributions.csproj"; var csFileName = "System.Linq.Dynamic.cs"; var solutionPortingResult = _resultsDict[version]; - var ruleContributionsResult = solutionPortingResult.ProjectResults.First(proj => proj.CsProjectPath.EndsWith(projectFileName)); + var ruleContributionsResult = solutionPortingResult.ProjectResults.First(proj => proj.CsProjectPath.EndsWith(RuleContributionsProjectFileName)); var ruleContributionsFile = Directory.EnumerateFiles(ruleContributionsResult.ProjectDirectory, "*.cs", SearchOption.AllDirectories) .First(file => file.EndsWith(csFileName)); var ruleContributionsFileContent = File.ReadAllText(ruleContributionsFile); - // Verify there are no build errors after porting - CollectionAssert.IsEmpty(solutionPortingResult.SolutionRunResult.BuildErrors); - // Verify expected package is in .csproj StringAssert.Contains(@"PackageReference Include=""System.Linq.Dynamic.Core""", ruleContributionsResult.CsProjectContent); @@ -63,4 +65,16 @@ public void TestProjectFilePortingResults(string version) StringAssert.Contains("using System.Linq.Dynamic.Core;", ruleContributionsFileContent); StringAssert.DoesNotContain("using System.Linq.Dynamic;", ruleContributionsFileContent); } + + [TestCase(TargetFramework.DotnetCoreApp31)] + [TestCase(TargetFramework.Dotnet5)] + [TestCase(TargetFramework.Dotnet6)] + public void BouncyCastleNetCore_Package_Is_Added(string version) + { + var solutionPortingResult = _resultsDict[version]; + var ruleContributionsResult = solutionPortingResult.ProjectResults.First(proj => proj.CsProjectPath.EndsWith(RuleContributionsProjectFileName)); + + // Verify expected package is in .csproj + StringAssert.Contains(@"PackageReference Include=""BouncyCastle.NetCore""", ruleContributionsResult.CsProjectContent); + } } \ No newline at end of file