Skip to content

Commit

Permalink
test: unit test for load reference util
Browse files Browse the repository at this point in the history
  • Loading branch information
cslong committed Jul 1, 2022
1 parent 8a1eba8 commit 861281d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tst/CTA.Rules.Test/UtilsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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<RootUstNode>()
{
new RootUstNode()
{
Children = new UstList<UstNode>
{
new ImportsStatement { Identifier = "Newtonsoft.Json"},
new UsingDirective {Identifier = "BouncyCastle.NetCore"}
},
References = new UstList<Reference>()
{
new Reference() {Namespace = "BouncyCastle.NetCore"}
}
}
}
}
};

var references = PortCoreUtils.GetReferencesForProject(analyzeResult);
Assert.IsTrue(references.Count == 2);
}
}
}

0 comments on commit 861281d

Please sign in to comment.