public async Task GivenExistingStudy_WhenDeletingStudy_TheServerShouldReturnNoContentAndAllLevelsShouldBeRemoved() { var studyInstanceUid = TestUidGenerator.Generate(); var seriesInstanceUid = TestUidGenerator.Generate(); var sopInstanceUid = TestUidGenerator.Generate(); await CreateFile(studyInstanceUid, seriesInstanceUid, sopInstanceUid); DicomWebResponse response = await _client.DeleteStudyAsync(studyInstanceUid); Assert.Equal(HttpStatusCode.NoContent, response?.StatusCode); await VerifyAllRemoval(studyInstanceUid, seriesInstanceUid, sopInstanceUid); }
public async void GivenAMultipartRequestWithAnInvalidMultipartSection_WhenStoring_TheServerShouldReturnAccepted() { var request = new HttpRequestMessage(HttpMethod.Post, "studies"); request.Headers.Add(HeaderNames.Accept, DicomWebClient.MediaTypeApplicationDicomJson.MediaType); var multiContent = new MultipartContent("related"); multiContent.Headers.ContentType.Parameters.Add(new System.Net.Http.Headers.NameValueHeaderValue("type", $"\"{DicomWebClient.MediaTypeApplicationDicom.MediaType}\"")); var byteContent = new ByteArrayContent(Array.Empty <byte>()); byteContent.Headers.ContentType = DicomWebClient.MediaTypeApplicationDicom; multiContent.Add(byteContent); string studyInstanceUID = TestUidGenerator.Generate(); try { DicomFile validFile = Samples.CreateRandomDicomFile(studyInstanceUID); await using (MemoryStream stream = _recyclableMemoryStreamManager.GetStream()) { await validFile.SaveAsync(stream); var validByteContent = new ByteArrayContent(stream.ToArray()); validByteContent.Headers.ContentType = DicomWebClient.MediaTypeApplicationDicom; multiContent.Add(validByteContent); } request.Content = multiContent; DicomWebResponse <DicomDataset> response = await _client.PostMultipartContentAsync(multiContent, "studies"); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); ValidationHelpers.ValidateReferencedSopSequence( response.Value, ConvertToReferencedSopSequenceEntry(validFile.Dataset)); } finally { await _client.DeleteStudyAsync(studyInstanceUID); } }
void IDisposable.Dispose() { // xunit does not seem to call IAsyncDispose.DisposeAsync() // Also wait should be okay in a test context foreach (string studyUid in _createdDicomStudies) { _client.DeleteStudyAsync(studyUid).Wait(); } _createdDicomStudies.Clear(); }