From 861281d260347aea6ec89d7f9b6bdaa489c69b6c Mon Sep 17 00:00:00 2001 From: Chris Long Date: Fri, 1 Jul 2022 16:03:20 -0700 Subject: [PATCH] test: unit test for load reference util --- tst/CTA.Rules.Test/UtilsTest.cs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/tst/CTA.Rules.Test/UtilsTest.cs b/tst/CTA.Rules.Test/UtilsTest.cs index 7f0a5750..ce817b89 100644 --- a/tst/CTA.Rules.Test/UtilsTest.cs +++ b/tst/CTA.Rules.Test/UtilsTest.cs @@ -5,7 +5,10 @@ using System.IO; using System.Linq; using System.Threading.Tasks; +using Codelyzer.Analysis; +using Codelyzer.Analysis.Model; using CTA.Rules.Common.Helpers; +using CTA.Rules.PortCore; namespace CTA.Rules.Test { @@ -121,5 +124,34 @@ public void Test_Is_VisualBasic_Project() Assert.IsTrue(VisualBasicUtils.IsVisualBasicProject("C://user/john/repos/test.vbproj")); Assert.IsFalse(VisualBasicUtils.IsVisualBasicProject("vbprojproject.cs")); } + + [Test] + public void TestLoadReferencesFromProject() + { + var analyzeResult = new AnalyzerResult + { + ProjectResult = new ProjectWorkspace("dummy.csproj") + { + SourceFileResults = new UstList() + { + new RootUstNode() + { + Children = new UstList + { + new ImportsStatement { Identifier = "Newtonsoft.Json"}, + new UsingDirective {Identifier = "BouncyCastle.NetCore"} + }, + References = new UstList() + { + new Reference() {Namespace = "BouncyCastle.NetCore"} + } + } + } + } + }; + + var references = PortCoreUtils.GetReferencesForProject(analyzeResult); + Assert.IsTrue(references.Count == 2); + } } } \ No newline at end of file