Skip to content

Commit b411488

Browse files
committed
gh-65 Fix unit test
Signed-off-by: Victor Chang <[email protected]>
1 parent 9f55f5f commit b411488

File tree

3 files changed

+14
-30
lines changed

3 files changed

+14
-30
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -137,39 +137,20 @@ jobs:
137137
- name: Restore dependencies
138138
run: dotnet restore
139139
working-directory: ./src
140-
141-
- name: Begin SonarScanner
142-
env:
143-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
144-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
145-
shell: powershell
146-
run: .\.sonar\scanner\dotnet-sonarscanner begin /k:"Project-MONAI_monai-deploy-informatics-gateway" /o:"project-monai" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="src\${{ env.TEST_RESULTS }}\**\*.xml"
147140

148-
- name: Build
141+
- name: Build & Test
149142
env:
150143
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
151144
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
152145
shell: powershell
153-
run: dotnet build -c ${{ env.BUILD_CONFIG }} --nologo "${{ env.SOLUTION }}"
154-
working-directory: ./src
146+
run: |
147+
.\.sonar\scanner\dotnet-sonarscanner begin /k:"Project-MONAI_monai-deploy-informatics-gateway" /o:"project-monai" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths="src\${{ env.TEST_RESULTS }}\**\*.xml"
148+
pushd src
149+
dotnet build -c ${{ env.BUILD_CONFIG }} --nologo "${{ env.SOLUTION }}"
150+
Get-ChildItem -Recurse | Where-Object { $_.Name -like "*Test.csproj" } | ForEach-Object { dotnet test -c ${{ env.BUILD_CONFIG }} -v=minimal -r "${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings coverlet.runsettings $_.FullName }
151+
popd
152+
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
155153
156-
- name: Test
157-
env:
158-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
159-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
160-
shell: powershell
161-
run: Get-ChildItem -Recurse | Where-Object { $_.Name -like "*Test.csproj" } | ForEach-Object { dotnet test -c ${{ env.BUILD_CONFIG }} -v=minimal -r "${{ env.TEST_RESULTS }}" --collect:"XPlat Code Coverage" --settings coverlet.runsettings $_.FullName }
162-
working-directory: ./src
163-
164-
165-
- name: End SonarScanner
166-
env:
167-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168-
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
169-
shell: powershell
170-
run: .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
171-
172-
173154
- uses: codecov/codecov-action@v2
174155
with:
175156
token: ${{ secrets.CODECOV_TOKEN }}

src/InformaticsGateway/Test/Services/Scp/ScpServiceTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public ScpServiceTest()
5656
_loggerFactory.Setup(p => p.CreateLogger(It.IsAny<string>())).Returns(_logger.Object);
5757
_associationDataProvider.Setup(p => p.GetLogger(It.IsAny<string>())).Returns(_loggerInternal.Object);
5858
_associationDataProvider.Setup(p => p.Configuration).Returns(_configuration);
59+
_logger.Setup(p => p.IsEnabled(It.IsAny<LogLevel>())).Returns(true);
60+
_loggerInternal.Setup(p => p.IsEnabled(It.IsAny<LogLevel>())).Returns(true);
5961
}
6062

6163
[RetryFact(5, 250, DisplayName = "StartAsync - shall stop application if failed to start SCP listner")]
@@ -107,7 +109,7 @@ public async Task CEcho_ShallRejectCEchoRequests()
107109
Assert.Equal(DicomRejectSource.ServiceUser, exception.RejectSource);
108110
Assert.Equal(DicomRejectResult.Permanent, exception.RejectResult);
109111

110-
_loggerInternal.VerifyLogging($"Verification service is disabled: rejecting association", LogLevel.Warning, Times.Once());
112+
_loggerInternal.VerifyLogging($"Verification service is disabled: rejecting association.", LogLevel.Warning, Times.Once());
111113

112114
Assert.True(countdownEvent.Wait(1000));
113115
}
@@ -367,7 +369,7 @@ public async Task CStore_OnClientAbort()
367369

368370
await client.SendAsync(_cancellationTokenSource.Token, DicomClientCancellationMode.ImmediatelyAbortAssociation);
369371
Assert.True(countdownEvent.Wait(2000));
370-
_loggerInternal.VerifyLogging($"Aborted {DicomAbortSource.ServiceUser} with reason {DicomAbortReason.NotSpecified}", LogLevel.Warning, Times.Once());
372+
_loggerInternal.VerifyLogging($"Aborted {DicomAbortSource.ServiceUser} with reason {DicomAbortReason.NotSpecified}.", LogLevel.Warning, Times.Once());
371373
}
372374

373375
private ScpService CreateService()

src/InformaticsGateway/Test/Services/Storage/SpaceReclaimerServiceTest.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public async Task ShallHonorCancellationRequest()
6060
_logger.VerifyLogging("Space Reclaimer Service is stopping.", LogLevel.Information, Times.Once());
6161
}
6262

63-
[RetryFact(5, 250, DisplayName = "Shall delete files")]
63+
[RetryFact(10, 250, DisplayName = "Shall delete files")]
6464
public async Task ShallDeleteFiles()
6565
{
6666
var files = new List<FileStorageInfo>() {
@@ -96,6 +96,7 @@ public async Task ShallDeleteFiles()
9696
{
9797
Assert.False(_fileSystem.File.Exists(file.FilePath));
9898
}
99+
Assert.False(_fileSystem.Directory.Exists("/payloads/dir1"));
99100
Assert.True(_fileSystem.Directory.Exists("/payloads"));
100101

101102
_logger.VerifyLogging("Space Reclaimer Service canceled.", LogLevel.Warning, Times.Once());

0 commit comments

Comments
 (0)