-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup test dicom instances after tests complete (#1254)
Cleanup test dicom instances after tests complete
- Loading branch information
1 parent
5b5a5f5
commit de06ccc
Showing
17 changed files
with
247 additions
and
120 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
test/Microsoft.Health.Dicom.Web.Tests.E2E/Common/DicomInstanceId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// ------------------------------------------------------------------------------------------------- | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information. | ||
// ------------------------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using Dicom; | ||
using EnsureThat; | ||
using Microsoft.Health.Dicom.Core.Extensions; | ||
using Microsoft.Health.Dicom.Core.Features.Model; | ||
|
||
namespace Microsoft.Health.Dicom.Web.Tests.E2E.Common | ||
{ | ||
internal class DicomInstanceId | ||
{ | ||
private const StringComparison EqualsStringComparison = StringComparison.Ordinal; | ||
public DicomInstanceId(string studyInstanceUid, string seriesInstanceUid, string sopInstanceUid, string partitionName) | ||
{ | ||
StudyInstanceUid = EnsureArg.IsNotNullOrWhiteSpace(studyInstanceUid, nameof(studyInstanceUid)); | ||
SeriesInstanceUid = EnsureArg.IsNotNullOrWhiteSpace(seriesInstanceUid, nameof(seriesInstanceUid)); | ||
SopInstanceUid = EnsureArg.IsNotNullOrWhiteSpace(sopInstanceUid, nameof(sopInstanceUid)); | ||
PartitionName = partitionName; | ||
} | ||
|
||
public string StudyInstanceUid { get; } | ||
public string SeriesInstanceUid { get; } | ||
public string SopInstanceUid { get; } | ||
public string PartitionName { get; } | ||
|
||
public static DicomInstanceId FromDicomFile(DicomFile dicomFile, string partitionName = default) | ||
{ | ||
InstanceIdentifier instanceIdentifier = dicomFile.Dataset.ToInstanceIdentifier(); | ||
return new DicomInstanceId(instanceIdentifier.StudyInstanceUid, instanceIdentifier.SeriesInstanceUid, instanceIdentifier.SopInstanceUid, partitionName); | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (obj is DicomInstanceId instanceId) | ||
{ | ||
return StudyInstanceUid.Equals(instanceId.StudyInstanceUid, EqualsStringComparison) && | ||
SeriesInstanceUid.Equals(instanceId.SeriesInstanceUid, EqualsStringComparison) && | ||
SopInstanceUid.Equals(instanceId.SopInstanceUid, EqualsStringComparison) && | ||
PartitionName.Equals(instanceId.PartitionName, EqualsStringComparison); | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public override int GetHashCode() => HashCode.Combine(StudyInstanceUid, SeriesInstanceUid, SopInstanceUid, PartitionName); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.