public void TestFilterMatchingOne()
        {
            var layout = new DicomFilteredAnnotationLayout("dummy", "dummy");

            layout.Filters.Add(new KeyValuePair <string, string>("k1", "v1"));

            Assert.IsTrue(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "v1")
            }), "v1");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "v2")
            }), "v2");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "")
            }), "<empty>");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", null)
            }), "<null>");
        }
		public void TestFilterMatchingOne()
		{
			var layout = new DicomFilteredAnnotationLayout("dummy", "dummy");
			layout.Filters.Add(new KeyValuePair<string, string>("k1", "v1"));

			Assert.IsTrue(layout.IsMatch(new[]
			                             	{
			                             		new KeyValuePair<string, string>("k1", "v1")
			                             	}), "v1");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "v2")
			                              	}), "v2");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "")
			                              	}), "<empty>");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", null)
			                              	}), "<null>");
		}
Ejemplo n.º 3
0
        DicomFilteredAnnotationLayout CreateLayout(string identifier, string matchingLayoutId, string modality)
        {
            DicomFilteredAnnotationLayout newLayout = new DicomFilteredAnnotationLayout(identifier, matchingLayoutId);

            if (modality != "")
            {
                newLayout.Filters.Add(new KeyValuePair <string, string>("Modality", modality));
            }

            return(newLayout);
        }
Ejemplo n.º 4
0
        DicomFilteredAnnotationLayout CopyLayout(DicomFilteredAnnotationLayout layout, string newIdentifier)
        {
            DicomFilteredAnnotationLayout newLayout = new DicomFilteredAnnotationLayout(newIdentifier, layout.MatchingLayoutIdentifier);

            foreach (KeyValuePair <string, string> filter in layout.Filters)
            {
                newLayout.Filters.Add(filter);
            }

            return(newLayout);
        }
        public void TestFilterMatchingCatchAll()
        {
            var layout = new DicomFilteredAnnotationLayout("dummy", "dummy");

            Assert.IsTrue(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", ""),
                new KeyValuePair <string, string>("k2", ""),
                new KeyValuePair <string, string>("k3", ""),
                new KeyValuePair <string, string>("k4", ""),
                new KeyValuePair <string, string>("k5", "")
            }), "");
        }
		public void TestFilterMatchingCatchAll()
		{
			var layout = new DicomFilteredAnnotationLayout("dummy", "dummy");

			Assert.IsTrue(layout.IsMatch(new[]
			                             	{
			                             		new KeyValuePair<string, string>("k1", ""),
			                             		new KeyValuePair<string, string>("k2", ""),
			                             		new KeyValuePair<string, string>("k3", ""),
			                             		new KeyValuePair<string, string>("k4", ""),
			                             		new KeyValuePair<string, string>("k5", "")
			                             	}), "");
		}
        public void TestFilterMatchingMultiple()
        {
            var layout = new DicomFilteredAnnotationLayout("dummy", "dummy");

            layout.Filters.Add(new KeyValuePair <string, string>("k1", "v1"));
            layout.Filters.Add(new KeyValuePair <string, string>("k2", "v2"));
            layout.Filters.Add(new KeyValuePair <string, string>("k3", ""));
            layout.Filters.Add(new KeyValuePair <string, string>("k4", null));

            Assert.IsTrue(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "v1"),
                new KeyValuePair <string, string>("k2", "v2"),
                new KeyValuePair <string, string>("k3", ""),
                new KeyValuePair <string, string>("k4", null)
            }), "all match");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "asdf"),
                new KeyValuePair <string, string>("k2", "v2"),
                new KeyValuePair <string, string>("k3", ""),
                new KeyValuePair <string, string>("k4", null)
            }), "k1 not match");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "v1"),
                new KeyValuePair <string, string>("k2", "asdf"),
                new KeyValuePair <string, string>("k3", ""),
                new KeyValuePair <string, string>("k4", null)
            }), "k2 not match");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "v1"),
                new KeyValuePair <string, string>("k2", "v2"),
                new KeyValuePair <string, string>("k3", "asdf"),
                new KeyValuePair <string, string>("k4", null)
            }), "k3 not match");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "v1"),
                new KeyValuePair <string, string>("k2", "v2"),
                new KeyValuePair <string, string>("k3", ""),
                new KeyValuePair <string, string>("k4", "asdf")
            }), "k4 not match");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "asdf"),
                new KeyValuePair <string, string>("k2", "v2"),
                new KeyValuePair <string, string>("k3", "asdf"),
                new KeyValuePair <string, string>("k4", "asdf")
            }), "some not match");

            Assert.IsFalse(layout.IsMatch(new[]
            {
                new KeyValuePair <string, string>("k1", "v1"),
                new KeyValuePair <string, string>("k3", ""),
                new KeyValuePair <string, string>("k4", null)
            }), "some not present");
        }
Ejemplo n.º 8
0
        public void Test()
        {
            DicomFilteredAnnotationLayoutStore.Instance.Clear();

            IList <DicomFilteredAnnotationLayout> layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;

            Assert.AreEqual(0, layouts.Count);

            DicomFilteredAnnotationLayoutStore.Instance.Update(CreateLayout("testLayout1", "Dicom.MR", "MR"));
            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(1, layouts.Count);

            layouts = new List <DicomFilteredAnnotationLayout>();
            layouts.Clear();
            layouts.Add(CreateLayout("testLayout1", "Dicom.MR", "MR"));
            layouts.Add(CreateLayout("testLayout2", "Dicom.MG", "MG"));
            layouts.Add(CreateLayout("testLayout3", "Dicom.CT", "CT"));
            layouts.Add(CreateLayout("testLayout4", "Dicom.PT", "PT"));

            DicomFilteredAnnotationLayoutStore.Instance.Update(layouts);

            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(4, layouts.Count);

            ResourceResolver resolver = new ResourceResolver(this.GetType().Assembly);

            using (Stream stream = resolver.OpenResource("DicomFilteredAnnotationLayoutStoreDefaults.xml"))
            {
                StreamReader reader = new StreamReader(stream);
                DicomFilteredAnnotationLayoutStoreSettings.Default.FilteredLayoutSettingsXml = reader.ReadToEnd();
            }

            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml, layouts.Count);

            DicomFilteredAnnotationLayout layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.MR");

            layout            = CopyLayout(layout, "Dicom.Filtered.RT");
            layout.Filters[0] = new KeyValuePair <string, string>("Modality", "RT");

            DicomFilteredAnnotationLayoutStore.Instance.Update(layout);
            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 1, layouts.Count);

            layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.RT");
            Assert.IsNotNull(layout);

            DicomFilteredAnnotationLayoutStore.Instance.RemoveFilteredLayout("Dicom.Filtered.RT");
            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml, layouts.Count);

            layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.RT");
            Assert.IsNull(layout);

            layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.MR");
            Assert.IsNotNull(layout);

            layouts = new List <DicomFilteredAnnotationLayout>();
            layouts.Clear();
            layouts.Add(CreateLayout("Dicom.Filtered.RT", "Dicom.RT", "RT"));
            layouts.Add(CreateLayout("Dicom.Filtered.SC", "Dicom.SC", "SC"));
            layouts.Add(CreateLayout("Dicom.Filtered.US", "Dicom.US", "US"));
            layouts.Add(CreateLayout("Dicom.Filtered.ES", "Dicom.ES", "ES"));

            DicomFilteredAnnotationLayoutStore.Instance.Update(layouts);

            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 4, layouts.Count);

            DicomFilteredAnnotationLayoutStore.Instance.RemoveFilteredLayout("Dicom.Filtered.RT");
            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 3, layouts.Count);

            DicomFilteredAnnotationLayoutStore.Instance.RemoveFilteredLayout("Dicom.Filtered.SC");
            layouts = DicomFilteredAnnotationLayoutStore.Instance.FilteredLayouts;
            Assert.AreEqual(_countLayoutsInDicomFilteredLayoutStoreXml + 2, layouts.Count);

            layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.AllMatch");
            Assert.IsNotNull(layout);
            Assert.AreEqual(0, layout.Filters.Count);

            layout = DicomFilteredAnnotationLayoutStore.Instance.GetFilteredLayout("Dicom.Filtered.MR");
            Assert.AreEqual(1, layout.Filters.Count);
        }
		DicomFilteredAnnotationLayout CreateLayout(string identifier, string matchingLayoutId, string modality)
		{
			DicomFilteredAnnotationLayout newLayout = new DicomFilteredAnnotationLayout(identifier, matchingLayoutId);
			if (modality != "")
				newLayout.Filters.Add(new KeyValuePair<string,string>("Modality", modality));
			
			return newLayout;
		}
		DicomFilteredAnnotationLayout CopyLayout(DicomFilteredAnnotationLayout layout, string newIdentifier)
		{
			DicomFilteredAnnotationLayout newLayout = new DicomFilteredAnnotationLayout(newIdentifier, layout.MatchingLayoutIdentifier);
			foreach (KeyValuePair<string, string> filter in layout.Filters)
				newLayout.Filters.Add(filter);

			return newLayout;
		}
		public void TestFilterMatchingMultiple()
		{
			var layout = new DicomFilteredAnnotationLayout("dummy", "dummy");
			layout.Filters.Add(new KeyValuePair<string, string>("k1", "v1"));
			layout.Filters.Add(new KeyValuePair<string, string>("k2", "v2"));
			layout.Filters.Add(new KeyValuePair<string, string>("k3", ""));
			layout.Filters.Add(new KeyValuePair<string, string>("k4", null));

			Assert.IsTrue(layout.IsMatch(new[]
			                             	{
			                             		new KeyValuePair<string, string>("k1", "v1"),
			                             		new KeyValuePair<string, string>("k2", "v2"),
			                             		new KeyValuePair<string, string>("k3", ""),
			                             		new KeyValuePair<string, string>("k4", null)
			                             	}), "all match");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "asdf"),
			                              		new KeyValuePair<string, string>("k2", "v2"),
			                              		new KeyValuePair<string, string>("k3", ""),
			                              		new KeyValuePair<string, string>("k4", null)
			                              	}), "k1 not match");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "v1"),
			                              		new KeyValuePair<string, string>("k2", "asdf"),
			                              		new KeyValuePair<string, string>("k3", ""),
			                              		new KeyValuePair<string, string>("k4", null)
			                              	}), "k2 not match");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "v1"),
			                              		new KeyValuePair<string, string>("k2", "v2"),
			                              		new KeyValuePair<string, string>("k3", "asdf"),
			                              		new KeyValuePair<string, string>("k4", null)
			                              	}), "k3 not match");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "v1"),
			                              		new KeyValuePair<string, string>("k2", "v2"),
			                              		new KeyValuePair<string, string>("k3", ""),
			                              		new KeyValuePair<string, string>("k4", "asdf")
			                              	}), "k4 not match");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "asdf"),
			                              		new KeyValuePair<string, string>("k2", "v2"),
			                              		new KeyValuePair<string, string>("k3", "asdf"),
			                              		new KeyValuePair<string, string>("k4", "asdf")
			                              	}), "some not match");

			Assert.IsFalse(layout.IsMatch(new[]
			                              	{
			                              		new KeyValuePair<string, string>("k1", "v1"),
			                              		new KeyValuePair<string, string>("k3", ""),
			                              		new KeyValuePair<string, string>("k4", null)
			                              	}), "some not present");
		}