public void TestDisplaySetSortByPresentationIntent() { var dxForPresentation1 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series1ForPres", 1, true); var dxForProcessing1 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series2ForProc", 2, false); var dxForOther1 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series3ForShaiHulud", 3, null); var dxForPresentation2 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series4ForPres", 4, true); var dxForProcessing2 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series5ForProc", 5, false); var dxForOther2 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series6ForTheHorde", 6, null); var dxForPresentation3 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series7ForPres", 7, true); var dxForProcessing3 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series8ForProc", 8, false); var dxForOther3 = CreateDXSopSeries(1, "PatientPeon", "StudyA", "Series9ForAiur", 9, null); var oldSynchronizationContext = SynchronizationContext.Current; SynchronizationContext.SetSynchronizationContext(oldSynchronizationContext ?? new SynchronizationContext()); try { using (var studyProviderContext = UnitTestStudyLoader.RegisterStudies(Combine(dxForOther1, dxForOther2, dxForOther3, dxForPresentation1, dxForPresentation2, dxForPresentation3, dxForProcessing1, dxForProcessing2, dxForProcessing3))) { using (var viewer = new ImageViewerComponent(new LayoutManager())) { viewer.LoadStudy(new LoadStudyArgs(HashUid("StudyA"), studyProviderContext.Server)); viewer.Layout(); Assert.AreEqual(9, viewer.LogicalWorkspace.ImageSets[0].DisplaySets.Count, "There should be 9 display sets here"); // FOR PRESENTATION series should be sorted to the front. Assert.AreEqual("Series1ForPres", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[0].Description, "FOR PRESENTATION and indeterminate series should be sorted to the front, subsorted by series number"); Assert.AreEqual("Series4ForPres", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[1].Description, "FOR PRESENTATION and indeterminate series should be sorted to the front, subsorted by series number"); Assert.AreEqual("Series7ForPres", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[2].Description, "FOR PRESENTATION and indeterminate series should be sorted to the front, subsorted by series number"); // FOR PROCESSING and indeterminate series are equivalent and are sorted to the end. Assert.AreEqual("Series2ForProc", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[3].Description, "FOR PROCESSING series should be sorted to the back, subsorted by series number"); Assert.AreEqual("Series3ForShaiHulud", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[4].Description, "FOR PRESENTATION and indeterminate series should be sorted to the front, subsorted by series number"); Assert.AreEqual("Series5ForProc", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[5].Description, "FOR PROCESSING series should be sorted to the back, subsorted by series number"); Assert.AreEqual("Series6ForTheHorde", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[6].Description, "FOR PRESENTATION and indeterminate series should be sorted to the front, subsorted by series number"); Assert.AreEqual("Series8ForProc", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[7].Description, "FOR PROCESSING series should be sorted to the back, subsorted by series number"); Assert.AreEqual("Series9ForAiur", viewer.LogicalWorkspace.ImageSets[0].DisplaySets[8].Description, "FOR PRESENTATION and indeterminate series should be sorted to the front, subsorted by series number"); } } } finally { SynchronizationContext.SetSynchronizationContext(oldSynchronizationContext); Dispose(dxForOther1, dxForOther2, dxForOther3, dxForPresentation1, dxForPresentation2, dxForPresentation3, dxForProcessing1, dxForProcessing2, dxForProcessing3); } }