public int[] WorkflowSubmission(string[] filepaths, string[] uris, int workflowId) { if (_submissionsClient == null) { throw new InvalidOperationException("No Init method was called before."); } bool filepathsProvided = filepaths != null && filepaths.Any(); bool urisProvided = uris != null && uris.Any(); if (!filepathsProvided && !urisProvided) { throw new ArgumentException("No uris or filepaths provided."); } if (filepathsProvided && urisProvided) { throw new ArgumentException("Provided uris and filepaths. Pass only one of the parameters."); } try { if (filepathsProvided) { return(Task.Run(async() => await _submissionsClient.CreateAsync(workflowId, filepaths)).GetAwaiter().GetResult().ToArray()); } return(Task.Run(async() => await _submissionsClient.CreateAsync(workflowId, uris.Select(u => new Uri(u)))).GetAwaiter().GetResult().ToArray()); } catch (System.Exception ex) { //AA doesn't understand custom exception types and the only important thing is message, so method catches all exceptions and throw new generic one with the correct message. throw new System.Exception(ex.Message); } }
public async Task CreateAsync_ShouldCreateSubmission_FromStream() { // Arrange var workflow = await _dataHelper.Workflows().GetAnyWorkflow(); await using var fileStream = _dataHelper.Files().GetSampleFileStream(); // Act var submissionIds = await _submissionsClient.CreateAsync(workflow.Id, new[] { fileStream }); // Assert var submissionId = submissionIds.Single(); submissionId.Should().BeGreaterThan(0); }
public async Task <int> GetNewId() { var submissionIds = await _submissions.CreateAsync( (await _workflows.GetAny()).Id, new Uri[] { new Uri("https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf") }); return(submissionIds.First()); }
public async Task <ISubmission> GetAnyAsync(Stream content) { var workflow = await _workflowHelper.GetAnyWorkflow(); var submissionIds = await _submissions.CreateAsync(workflow.Id, new [] { content ?? throw new ArgumentNullException(nameof(content)) });