public void TestProcessMessage() { try { Assert.IsNotNull(SynchronizationContext.Current, "SynchronizationContext.Current"); DicomFile file = new DicomFile("TileEntityHandlerTest.dcm"); DicomAttributeCollection dataSet = file.DataSet; SetupSecondaryCapture(dataSet); file.Save(); ImageViewerComponent viewer = new ImageViewerComponent(); viewer.Start(); viewer.LoadImages(new[] { "TileEntityHandlerTest.dcm" }); ManualResetEvent signal = new ManualResetEvent(false); viewer.EventBroker.LayoutManagerCompleted += (s, e) => signal.Set(); viewer.Layout(); Console.WriteLine("Waiting for layout to complete"); if (!signal.WaitOne(20000)) { Assert.Fail("Abort: something is not working properly."); } Console.WriteLine("Layout completed"); Assert.IsNotNull(viewer.PhysicalWorkspace); Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0]); Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0]); Tile tile = viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0] as Tile; Assert.IsNotNull(tile.PresentationImage); MockApplicationContext context = new MockApplicationContext(); TileEntityHandler handler = new TileEntityHandler { ApplicationContext = context }; handler.SetModelObject(tile); ChangeClientRectangle(context, handler, 0, 0, 512, 512, "Case: Size is even"); ChangeClientRectangle(context, handler, 0, 0, 311, 311, "Case: Size is odd"); ChangeClientRectangle(context, handler, 10, 10, 300, 301, "Case: Left,Top are positive"); ChangeClientRectangle(context, handler, -10, -10, 512, 512, "Case: Left,Top are negative"); } finally { File.Delete("TileEntityHandlerTest.dcm"); } }
public void TestProcessMessage() { try { Assert.IsNotNull(SynchronizationContext.Current, "SynchronizationContext.Current"); DicomFile file = new DicomFile("TileEntityHandlerTest.dcm"); DicomAttributeCollection dataSet = file.DataSet; SetupSecondaryCapture(dataSet); file.Save(); ImageViewerComponent viewer = new ImageViewerComponent(); viewer.Start(); viewer.LoadImages(new[] { "TileEntityHandlerTest.dcm" }); ManualResetEvent signal = new ManualResetEvent(false); viewer.EventBroker.LayoutManagerCompleted += (s, e) => signal.Set(); viewer.Layout(); Console.WriteLine("Waiting for layout to complete"); if (!signal.WaitOne(20000)) Assert.Fail("Abort: something is not working properly."); Console.WriteLine("Layout completed"); Assert.IsNotNull(viewer.PhysicalWorkspace); Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0]); Assert.IsNotNull(viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0]); Tile tile = viewer.PhysicalWorkspace.ImageBoxes[0].Tiles[0] as Tile; Assert.IsNotNull(tile.PresentationImage); MockApplicationContext context = new MockApplicationContext(); TileEntityHandler handler = new TileEntityHandler { ApplicationContext = context }; handler.SetModelObject(tile); ChangeClientRectangle(context, handler, 0, 0, 512, 512, "Case: Size is even"); ChangeClientRectangle(context, handler, 0, 0, 311, 311, "Case: Size is odd"); ChangeClientRectangle(context, handler, 10, 10, 300, 301, "Case: Left,Top are positive"); ChangeClientRectangle(context, handler, -10, -10, 512, 512, "Case: Left,Top are negative"); } finally { File.Delete("TileEntityHandlerTest.dcm"); } }
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); } }