diff --git a/COMET.Web.Common.Tests/Services/SessionManagement/SessionServiceTestFixture.cs b/COMET.Web.Common.Tests/Services/SessionManagement/SessionServiceTestFixture.cs index dc6df73d..63864c32 100644 --- a/COMET.Web.Common.Tests/Services/SessionManagement/SessionServiceTestFixture.cs +++ b/COMET.Web.Common.Tests/Services/SessionManagement/SessionServiceTestFixture.cs @@ -342,18 +342,18 @@ public void VerifyUpdateThings() var clone = element.Clone(false); clone.Name = "Satellite"; thingsToUpdate.Add(clone); - Assert.DoesNotThrowAsync(async() => await this.sessionService.UpdateThings(this.iteration, thingsToUpdate)); + Assert.That(async () => await this.sessionService.UpdateThings(this.iteration, thingsToUpdate), Throws.Nothing); var filesToUpload = new List { this.uri.LocalPath }; Assert.Multiple(() => { - Assert.DoesNotThrowAsync(async () => await this.sessionService.UpdateThings(this.iteration, thingsToUpdate, filesToUpload)); + Assert.That(async () => await this.sessionService.UpdateThings(this.iteration, thingsToUpdate, filesToUpload), Throws.Nothing); this.session.Verify(x => x.Write(It.IsAny(), It.IsAny>()), Times.Once); }); this.session.Setup(x => x.Write(It.IsAny(), It.IsAny>())).Throws(new DalWriteException()); - Assert.DoesNotThrowAsync(async () => await this.sessionService.UpdateThings(this.iteration, thingsToUpdate, filesToUpload)); + Assert.That(async () => await this.sessionService.UpdateThings(this.iteration, thingsToUpdate, filesToUpload), Throws.Nothing); } [Test] diff --git a/COMETwebapp.Tests/Services/Interoperability/JsUtilitiesServiceTestFixture.cs b/COMETwebapp.Tests/Services/Interoperability/JsUtilitiesServiceTestFixture.cs index f49fefef..e453c299 100644 --- a/COMETwebapp.Tests/Services/Interoperability/JsUtilitiesServiceTestFixture.cs +++ b/COMETwebapp.Tests/Services/Interoperability/JsUtilitiesServiceTestFixture.cs @@ -48,9 +48,12 @@ public void SetUp() [Test] public async Task VerifyFileDownloadUtility() { - Assert.ThrowsAsync(async () => await this.service.DownloadFileFromStreamAsync(null, null)); - Assert.ThrowsAsync(async () => await this.service.DownloadFileFromStreamAsync(new MemoryStream(), null)); - + Assert.Multiple(() => + { + Assert.That(async () => await this.service.DownloadFileFromStreamAsync(null, null), Throws.ArgumentNullException); + Assert.That(async () => await this.service.DownloadFileFromStreamAsync(new MemoryStream(), null), Throws.ArgumentNullException); + }); + await this.service.DownloadFileFromStreamAsync(new MemoryStream(), "fileTest"); Assert.That(this.jsRuntimeMock.Invocations.Count, Is.EqualTo(1)); } diff --git a/COMETwebapp/Extensions/FolderExtensions.cs b/COMETwebapp/Extensions/FolderExtensions.cs index 2bfcf83f..ff9c5c6e 100644 --- a/COMETwebapp/Extensions/FolderExtensions.cs +++ b/COMETwebapp/Extensions/FolderExtensions.cs @@ -38,8 +38,7 @@ public static class FolderExtensions /// The path public static string GetFolderPath(this Folder folder) { - var path = $"{folder.Path}/{folder.Name}/"; - return path; + return Path.Combine(folder.Path, folder.Name); } } } diff --git a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs index aeac7abb..04eafd7b 100644 --- a/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs +++ b/COMETwebapp/ViewModels/Components/EngineeringModel/FileStore/FileRevisionHandler/FileRevisionHandlerViewModel.cs @@ -126,8 +126,7 @@ public void InitializeViewModel(File file, FileStore fileStore) this.CurrentFileStore = fileStore; this.FileTypes = this.SessionService.GetSiteDirectory().AvailableReferenceDataLibraries().SelectMany(x => x.FileType); this.ErrorMessage = string.Empty; - - this.UploadsDirectory = $"wwwroot/uploads/{Guid.NewGuid()}"; + this.UploadsDirectory = Path.Combine("wwwroot", "uploads", Guid.NewGuid().ToString()); if (!Directory.Exists(this.UploadsDirectory)) { diff --git a/COMETwebapp/wwwroot/Scripts/utilities.js b/COMETwebapp/wwwroot/Scripts/utilities.js index a5214369..7dd68a94 100644 --- a/COMETwebapp/wwwroot/Scripts/utilities.js +++ b/COMETwebapp/wwwroot/Scripts/utilities.js @@ -3,20 +3,18 @@ * @param {string} fileName * @param {any} contentStreamReference */ -function DownloadFileFromStream(fileName, contentStreamReference) { - (async () => { - const arrayBuffer = await contentStreamReference.arrayBuffer(); - const blob = new Blob([arrayBuffer], { type: 'text/plain;charset=utf-8' }); +async function DownloadFileFromStream(fileName, contentStreamReference) { + const arrayBuffer = await contentStreamReference.arrayBuffer(); + const blob = new Blob([arrayBuffer], { type: 'text/plain;charset=utf-8' }); - const url = URL.createObjectURL(blob); + const url = URL.createObjectURL(blob); - const anchorElement = document.createElement('a'); + const anchorElement = document.createElement('a'); - anchorElement.href = url; - anchorElement.download = fileName ?? ''; - anchorElement.target = "_blank"; - anchorElement.click(); - anchorElement.remove(); - URL.revokeObjectURL(url); - })(); + anchorElement.href = url; + anchorElement.download = fileName ?? ''; + anchorElement.target = "_blank"; + anchorElement.click(); + anchorElement.remove(); + URL.revokeObjectURL(url); } \ No newline at end of file