Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add threading tests
Browse files Browse the repository at this point in the history
georgii-borovinskikh-sonarsource committed Nov 1, 2024
1 parent de4c0c5 commit d904703
Showing 1 changed file with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -48,7 +48,7 @@ public void TestInitialize()
loaderFactory.Create().Returns(analyzerAssemblyLoader);
logger = Substitute.For<ILogger>();
indicator = Substitute.For<IConfigurationScopeDotnetAnalyzerIndicator>();
threadHandling = Substitute.ForPartsOf<NoOpThreadHandler>();
threadHandling = new NoOpThreadHandler();

testSubject = new EmbeddedDotnetAnalyzerProvider(locator, loaderFactory, indicator, logger, threadHandling);
MockServices();
@@ -95,13 +95,43 @@ public void GetBasicAsync_GetsAnalyzersFromExpectedLocation()
locator.Received(1).GetBasicAnalyzerFullPaths();
}

[TestMethod]
public void GetBasicAsync_RunsOnBackgroundThread()
{
var threadHandlingMock = Substitute.For<IThreadHandling>();
var subject = new EmbeddedDotnetAnalyzerProvider(default,
Substitute.For<IAnalyzerAssemblyLoaderFactory>(),
default,
default,
threadHandlingMock);

subject.GetBasicAsync();

threadHandlingMock.Received(1).RunOnBackgroundThread(Arg.Any<Func<Task<ImmutableArray<AnalyzerFileReference>>>>());
}

[TestMethod]
public void GetEnterpriseOrNullAsync_GetsAnalyzersFromExpectedLocation()
{
testSubject.GetEnterpriseOrNullAsync("scope");

locator.Received(1).GetEnterpriseAnalyzerFullPaths();
}

[TestMethod]
public void GetEnterpriseOrNullAsync_RunsOnBackgroundThread()
{
var threadHandlingMock = Substitute.For<IThreadHandling>();
var subject = new EmbeddedDotnetAnalyzerProvider(default,
Substitute.For<IAnalyzerAssemblyLoaderFactory>(),
default,
default,
threadHandlingMock);

subject.GetEnterpriseOrNullAsync("scope");

threadHandlingMock.Received(1).RunOnBackgroundThread(Arg.Any<Func<Task<ImmutableArray<AnalyzerFileReference>?>>>());
}

[TestMethod]
public async Task GetBasicAsync_AnalyzerFilesExist_ReturnsAnalyzerFileReference()

0 comments on commit d904703

Please sign in to comment.