Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAN-454] Fix task-completion-source task-leaks #162

Merged
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:

- name: '📡 Publish Test Results' # https://github.com/marketplace/actions/publish-test-results
uses: 'EnricoMi/publish-unit-test-result-action/macos@v2'
if: always()
if: always() # this means: "run even if prior steps fail" if tests fail, the build will fail, but at least we will know exactly what failed
with:
files: |
TestResults/**/TEST-*.xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1087.0</Version>
<FileVersion>1.0.1087.0</FileVersion>
<PackageVersion>1.0.1087.0</PackageVersion>
<AssemblyVersion>1.0.1087.0</AssemblyVersion>
<Version>1.0.1092.0</Version>
<FileVersion>1.0.1092.0</FileVersion>
<PackageVersion>1.0.1092.0</PackageVersion>
<AssemblyVersion>1.0.1092.0</AssemblyVersion>

<Title>$(PackageId)</Title>
<Owners>$(Authors)</Owners>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.pdb</AllowedReferenceRelatedFileExtensions>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1177.0</Version>
<FileVersion>1.0.1177.0</FileVersion>
<PackageVersion>1.0.1177.0</PackageVersion>
<AssemblyVersion>1.0.1177.0</AssemblyVersion>
<Version>1.0.1092.0</Version>
<FileVersion>1.0.1092.0</FileVersion>
<PackageVersion>1.0.1092.0</PackageVersion>
<AssemblyVersion>1.0.1092.0</AssemblyVersion>

<Title>$(PackageId)</Title>
<Summary>McuMgr Bindings for MacCatalyst - MAUI ready</Summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.pdb</AllowedReferenceRelatedFileExtensions>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1177.0</Version>
<FileVersion>1.0.1177.0</FileVersion>
<PackageVersion>1.0.1177.0</PackageVersion>
<AssemblyVersion>1.0.1177.0</AssemblyVersion>
<Version>1.0.1092.0</Version>
<FileVersion>1.0.1092.0</FileVersion>
<PackageVersion>1.0.1092.0</PackageVersion>
<AssemblyVersion>1.0.1092.0</AssemblyVersion>

<Title>$(PackageId)</Title>
<Summary>McuMgr C# Implementation (WIP)</Summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
<AllowedReferenceRelatedFileExtensions>$(AllowedReferenceRelatedFileExtensions);.pdb</AllowedReferenceRelatedFileExtensions>

<!-- these versions are getting replaced by the build script in one swift pass -->
<Version>1.0.1177.0</Version>
<FileVersion>1.0.1177.0</FileVersion>
<PackageVersion>1.0.1177.0</PackageVersion>
<AssemblyVersion>1.0.1177.0</AssemblyVersion>
<Version>1.0.1092.0</Version>
<FileVersion>1.0.1092.0</FileVersion>
<PackageVersion>1.0.1092.0</PackageVersion>
<AssemblyVersion>1.0.1092.0</AssemblyVersion>

<Title>$(PackageId)</Title>
<Summary>McuMgr Bindings for iOS - MAUI ready</Summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Enums;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.DeviceResetter.Contracts.Enums;
Expand All @@ -23,8 +24,7 @@ public async Task ResetAsync_ShouldThrowDeviceResetterErroredOutException_GivenB

// Assert
await work
.Should().ThrowExactlyAsync<DeviceResetterErroredOutException>()
.WithTimeoutInMs(500)
.Should().ThrowWithinAsync<DeviceResetterErroredOutException>(500.Milliseconds())
.WithMessage("*bluetooth error blah blah*");

mockedNativeDeviceResetterProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.DeviceResetter.Contracts.Enums;
using Laerdal.McuMgr.DeviceResetter.Contracts.Events;
Expand All @@ -21,7 +22,10 @@ public async Task ResetAsync_ShouldThrowDeviceResetterInternalErrorException_Giv
var work = new Func<Task>(() => deviceResetter.ResetAsync());

// Assert
(await work.Should().ThrowExactlyAsync<DeviceResetterInternalErrorException>().WithTimeoutInMs(100)).WithInnerExceptionExactly<Exception>("native symbols not loaded blah blah");
(await work
.Should()
.ThrowWithinAsync<DeviceResetterInternalErrorException>(500.Milliseconds())
).WithInnerExceptionExactly<Exception>("native symbols not loaded blah blah");

mockedNativeDeviceResetterProxy.DisconnectCalled.Should().BeFalse(); //00
mockedNativeDeviceResetterProxy.BeginResetCalled.Should().BeTrue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public async Task ResetAsync_ShouldThrowTimeoutException_GivenTooSmallTimeout()
var work = new Func<Task>(() => deviceResetter.ResetAsync(timeoutInMs: 100));

// Assert
await work.Should().ThrowExactlyAsync<DeviceResetTimeoutException>().WithTimeoutInMs((int)5.Seconds().TotalMilliseconds);
await work
.Should()
.ThrowWithinAsync<DeviceResetTimeoutException>(5.Seconds());

mockedNativeDeviceResetterProxy.DisconnectCalled.Should().BeFalse(); //00
mockedNativeDeviceResetterProxy.BeginResetCalled.Should().BeTrue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FileDownloader.Contracts.Enums;
using Laerdal.McuMgr.FileDownloader.Contracts.Native;
Expand Down Expand Up @@ -37,7 +38,7 @@ public async Task MultipleFilesDownloadAsync_ShouldThrowArgumentException_GivenP
));

// Assert
await work.Should().ThrowExactlyAsync<ArgumentException>().WithTimeoutInMs(500);
await work.Should().ThrowWithinAsync<ArgumentException>(500.Milliseconds());

eventsMonitor.OccurredEvents.Should().HaveCount(0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FileDownloader.Contracts.Enums;
using Laerdal.McuMgr.FileDownloader.Contracts.Native;
Expand Down Expand Up @@ -28,7 +29,7 @@ public async Task MultipleFilesDownloadAsync_ShouldThrowNullArgumentException_Gi
));

// Assert
await work.Should().ThrowExactlyAsync<ArgumentNullException>().WithTimeoutInMs(500);
await work.Should().ThrowWithinAsync<ArgumentNullException>(500.Milliseconds());

eventsMonitor.OccurredEvents.Should().HaveCount(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ public async Task SingleFileDownloadAsync_ShouldThrowAllDownloadAttemptsFailedEx

// Assert
await work.Should()
.ThrowExactlyAsync<AllDownloadAttemptsFailedException>()
.WithMessage("*failed to download*")
.WithTimeoutInMs((int)(maxTriesCount * 3).Seconds().TotalMilliseconds);
.ThrowWithinAsync<AllDownloadAttemptsFailedException>((maxTriesCount * 3).Seconds())
.WithMessage("*failed to download*");

mockedNativeFileDownloaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileDownloaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ public async Task SingleFileDownloadAsync_ShouldThrowAllDownloadAttemptsFailedEx

// Assert
await work.Should()
.ThrowExactlyAsync<AllDownloadAttemptsFailedException>()
.WithTimeoutInMs((int)3.Seconds().TotalMilliseconds);
.ThrowWithinAsync<AllDownloadAttemptsFailedException>(3.Seconds());

mockedNativeFileDownloaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileDownloaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FileDownloader.Contracts.Enums;
using Laerdal.McuMgr.FileDownloader.Contracts.Native;
Expand Down Expand Up @@ -29,7 +30,7 @@ public async Task SingleFileDownloadAsync_ShouldThrowArgumentException_GivenEmpt
));

// Assert
await work.Should().ThrowExactlyAsync<ArgumentException>().WithTimeoutInMs(500);
await work.Should().ThrowWithinAsync<ArgumentException>(500.Milliseconds());

mockedNativeFileDownloaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileDownloaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public async Task SingleFileUploadAsync_ShouldThrowUploadCancelledException_Give
));

// Assert
await work.Should().ThrowExactlyAsync<DownloadCancelledException>().WithTimeoutInMs((int)5.Seconds().TotalMilliseconds);
await work.Should().ThrowWithinAsync<DownloadCancelledException>(5.Seconds());

mockedNativeFileDownloaderProxy.CancelCalled.Should().BeTrue();
mockedNativeFileDownloaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public async Task SingleFileDownloadAsync_ShouldThrowDownloadTimeoutException_Gi
));

// Assert
await work.Should().ThrowExactlyAsync<DownloadTimeoutException>().WithTimeoutInMs((int)5.Seconds().TotalMilliseconds);
await work.Should().ThrowWithinAsync<DownloadTimeoutException>(5.Seconds());

mockedNativeFileDownloaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileDownloaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ public async Task SingleFileDownloadAsync_ShouldThrowRemoteFileNotFoundException

// Assert
await work.Should()
.ThrowExactlyAsync<DownloadErroredOutRemoteFileNotFoundException>()
.WithTimeoutInMs((int)3.Seconds().TotalMilliseconds);
.ThrowWithinAsync<DownloadErroredOutRemoteFileNotFoundException>(3.Seconds());

mockedNativeFileDownloaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileDownloaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FileUploader.Contracts.Enums;
using Laerdal.McuMgr.FileUploader.Contracts.Native;
Expand Down Expand Up @@ -36,7 +37,7 @@ public async Task MultipleFilesUploadAsync_ShouldThrowArgumentException_GivenPat
));

// Assert
await work.Should().ThrowAsync<ArgumentException>().WithTimeoutInMs(500); //dont use throwexactlyasync<> here
await work.Should().ThrowWithinAsync<ArgumentException>(500.Milliseconds()); //dont use throwexactlyasync<> here

eventsMonitor.OccurredEvents.Should().HaveCount(0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FileUploader.Contracts.Enums;
using Laerdal.McuMgr.FileUploader.Contracts.Native;
Expand Down Expand Up @@ -28,7 +29,7 @@ public async Task MultipleFilesUploadAsync_ShouldThrowNullArgumentException_Give
));

// Assert
await work.Should().ThrowExactlyAsync<ArgumentNullException>().WithTimeoutInMs(500);
await work.Should().ThrowWithinAsync<ArgumentNullException>(500.Milliseconds());

eventsMonitor.OccurredEvents.Should().HaveCount(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ public async Task SingleFileUploadAsync_ShouldThrowAllUploadAttemptsFailedExcept

// Assert
await work.Should()
.ThrowExactlyAsync<AllUploadAttemptsFailedException>()
.WithMessage("*failed to upload*")
.WithTimeoutInMs((int)((maxTriesCount + 1) * 3).Seconds().TotalMilliseconds);
.ThrowWithinAsync<AllUploadAttemptsFailedException>(((maxTriesCount + 1) * 3).Seconds())
.WithMessage("*failed to upload*");

mockedNativeFileUploaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileUploaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public async Task SingleFileUploadAsync_ShouldThrowAllUploadAttemptsFailedExcept
));

// Assert
await work.Should()
.ThrowExactlyAsync<AllUploadAttemptsFailedException>()
.WithTimeoutInMs((int)3.Seconds().TotalMilliseconds);
await work.Should().ThrowWithinAsync<AllUploadAttemptsFailedException>(3.Seconds());

mockedNativeFileUploaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileUploaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FileUploader.Contracts.Enums;
using Laerdal.McuMgr.FileUploader.Contracts.Native;
Expand Down Expand Up @@ -30,7 +31,7 @@ public async Task SingleFileUploadAsync_ShouldThrowArgumentException_GivenEmptyR
));

// Assert
await work.Should().ThrowExactlyAsync<ArgumentException>().WithTimeoutInMs(500);
await work.Should().ThrowWithinAsync<ArgumentException>(500.Milliseconds());

mockedNativeFileUploaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileUploaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ int maxTriesCount

// Assert
await work.Should()
.ThrowExactlyAsync<UploadErroredOutRemoteFolderNotFoundException>()
.WithTimeoutInMs((int)3.Seconds().TotalMilliseconds);
.ThrowWithinAsync<UploadErroredOutRemoteFolderNotFoundException>(3.Seconds());

mockedNativeFileUploaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileUploaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task SingleFileUploadAsync_ShouldThrowUploadCancelledException_Give
));

// Assert
await work.Should().ThrowExactlyAsync<UploadCancelledException>().WithTimeoutInMs((int)5.Seconds().TotalMilliseconds);
await work.Should().ThrowWithinAsync<UploadCancelledException>(5.Seconds());

mockedNativeFileUploaderProxy.CancelCalled.Should().BeTrue();
mockedNativeFileUploaderProxy.CancellationReason.Should().Be(cancellationReason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public async Task SingleFileUploadAsync_ShouldThrowUploadTimeoutException_GivenT
));

// Assert
await work.Should().ThrowExactlyAsync<UploadTimeoutException>().WithTimeoutInMs((int)5.Seconds().TotalMilliseconds);
await work.Should().ThrowWithinAsync<UploadTimeoutException>(5.Seconds());

mockedNativeFileUploaderProxy.CancelCalled.Should().BeFalse();
mockedNativeFileUploaderProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public async Task EraseAsync_ShouldThrowTimeoutException_GivenTooSmallTimeout()
var work = new Func<Task>(() => firmwareEraser.EraseAsync(imageIndex: 2, timeoutInMs: 100));

// Assert
await work.Should().ThrowExactlyAsync<FirmwareErasureTimeoutException>().WithTimeoutInMs((int)5.Seconds().TotalMilliseconds);
await work.Should().ThrowWithinAsync<FirmwareErasureTimeoutException>(5.Seconds());

mockedNativeFirmwareEraserProxy.DisconnectCalled.Should().BeFalse(); //00
mockedNativeFirmwareEraserProxy.BeginErasureCalled.Should().BeTrue();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Enums;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FirmwareInstaller.Contracts.Enums;
Expand Down Expand Up @@ -32,9 +33,7 @@ public async Task InstallAsync_ShouldThrowAllFirmwareInstallationAttemptsFailedE

// Assert
(
await work.Should()
.ThrowExactlyAsync<AllFirmwareInstallationAttemptsFailedException>()
.WithTimeoutInMs(3_000)
await work.Should().ThrowWithinAsync<AllFirmwareInstallationAttemptsFailedException>(3_000.Milliseconds())
).WithInnerException<FirmwareInstallationUploadingStageErroredOutException>();

mockedNativeFirmwareInstallerProxy.CancelCalled.Should().BeFalse();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Enums;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FirmwareInstaller.Contracts.Enums;
Expand Down Expand Up @@ -30,9 +31,9 @@ public async Task InstallAsync_ShouldThrowAllFirmwareInstallationAttemptsFailedE

// Assert
await work.Should()
.ThrowExactlyAsync<FirmwareInstallationErroredOutException>() // todo AllFirmwareInstallationAttemptsFailedException
.WithMessage("*fatal error occurred*")
.WithTimeoutInMs(3_000);
.ThrowWithinAsync<AllFirmwareInstallationAttemptsFailedException>(3_000.Milliseconds())
.WithInnerException(typeof(FirmwareInstallationUploadingStageErroredOutException))
.WithMessage("*fatal error occurred 123*");

mockedNativeFirmwareInstallerProxy.CancelCalled.Should().BeFalse();
mockedNativeFirmwareInstallerProxy.DisconnectCalled.Should().BeFalse(); //00
Expand All @@ -43,7 +44,7 @@ await work.Should()
eventsMonitor
.Should().Raise(nameof(firmwareInstaller.FatalErrorOccurred))
.WithSender(firmwareInstaller)
.WithArgs<FatalErrorOccurredEventArgs>(args => args.ErrorMessage == "fatal error occurred");
.WithArgs<FatalErrorOccurredEventArgs>(args => args.ErrorMessage == "fatal error occurred 123");

eventsMonitor
.Should().Raise(nameof(firmwareInstaller.StateChanged))
Expand Down Expand Up @@ -103,7 +104,7 @@ public override EFirmwareInstallationVerdict BeginInstallation(
await Task.Delay(100);

StateChangedAdvertisement(EFirmwareInstallationState.Uploading, EFirmwareInstallationState.Error); // order
FatalErrorOccurredAdvertisement(EFirmwareInstallationState.Confirming, EFirmwareInstallerFatalErrorType.Generic, "fatal error occurred", EGlobalErrorCode.Generic); // order
FatalErrorOccurredAdvertisement(EFirmwareInstallationState.Uploading, EFirmwareInstallerFatalErrorType.Generic, "fatal error occurred 123", EGlobalErrorCode.Generic); // order
});

return verdict;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FluentAssertions;
using FluentAssertions.Extensions;
using Laerdal.McuMgr.Common.Enums;
using Laerdal.McuMgr.Common.Helpers;
using Laerdal.McuMgr.FirmwareInstaller.Contracts.Enums;
Expand Down Expand Up @@ -29,9 +30,7 @@ public async Task InstallAsync_ShouldThrowFirmwareInstallationImageSwapTimeoutEx
));

// Assert
await work.Should()
.ThrowExactlyAsync<FirmwareInstallationConfirmationStageTimeoutException>()
.WithTimeoutInMs(3_000);
await work.Should().ThrowWithinAsync<FirmwareInstallationConfirmationStageTimeoutException>(3_000.Milliseconds());

mockedNativeFirmwareInstallerProxy.CancelCalled.Should().BeFalse();
mockedNativeFirmwareInstallerProxy.DisconnectCalled.Should().BeFalse(); //00
Expand Down
Loading
Loading