public static void TestPerturb()
        {
            var tag1 = DicomTag.Reference​Pixel​X0;       // SL VM =1
            var tag2 = DicomTag.Rational​Numerator​Value; // SL Vm=1-n
            var tag3 = DicomTag.Detector​Temperature;     // DS VM = 1
            var tag4 = DicomTag.Filter​Thickness​Minimum; // DS VM = 1-n

            var dataset = new DicomDataset
            {
                { tag1, 1234 },
                { tag2, 1234, -1234, 4321, -4321 },
                { tag3, "1234.5" },
                { tag4, "1234.5", "-1234.5" },
            };

            var itemList = dataset.ToArray();

            var redactProcess = new PerturbProcessor();
            var settings      = new Dictionary <string, object> {
                { "span", 1 }, { "roundTo", 2 }, { "rangeType", "proportional" }
            };

            foreach (var item in itemList)
            {
                redactProcess.Process(dataset, item, settings);
            }
        }
Exemple #2
0
        public void GivenAnIntegerNode_WhenPerturbProportionalSpan_PerturbedNodeShouldBeReturned(Base data, decimal span, decimal roundTo, decimal lowerBound, decimal upperBound)
        {
            var node = ElementNode.FromElement(data.ToTypedElement());
            PerturbProcessor processor = new PerturbProcessor();
            var context = new ProcessContext
            {
                VisitedNodes = new HashSet <ElementNode>()
            };
            var settings = new Dictionary <string, object> {
                { "span", span }, { "roundTo", roundTo }, { "rangeType", "proportional" }
            };

            var processResult = processor.Process(node, context, settings);

            Assert.True(processResult.IsPerturbed);
            var perturbedValue = decimal.Parse(node.Value.ToString());

            Assert.InRange(perturbedValue, lowerBound, upperBound);
            Assert.True(GetDecimalPlaces(perturbedValue) == 0);
        }
        private Dictionary <string, IAnonymizerProcessor> CreateTestProcessors()
        {
            KeepProcessor       keepProcessor       = new KeepProcessor();
            RedactProcessor     redactProcessor     = new RedactProcessor(false, false, false, null);
            DateShiftProcessor  dateShiftProcessor  = new DateShiftProcessor("123", "123", false);
            CryptoHashProcessor cryptoHashProcessor = new CryptoHashProcessor("123");
            EncryptProcessor    encryptProcessor    = new EncryptProcessor("1234567890123456");
            SubstituteProcessor substituteProcessor = new SubstituteProcessor();
            PerturbProcessor    perturbProcessor    = new PerturbProcessor();
            Dictionary <string, IAnonymizerProcessor> processors = new Dictionary <string, IAnonymizerProcessor>()
            {
                { "KEEP", keepProcessor },
                { "REDACT", redactProcessor },
                { "DATESHIFT", dateShiftProcessor },
                { "CRYPTOHASH", cryptoHashProcessor },
                { "ENCRYPT", encryptProcessor },
                { "SUBSTITUTE", substituteProcessor },
                { "PERTURB", perturbProcessor }
            };

            return(processors);
        }
        public PerturbProcessorUnitTests()
        {
            var json = "{\"span\": \"1\",\"roundTo\": \"2\", \"rangeType\": \"Proportional\"}";

            Processor = new PerturbProcessor(JObject.Parse(json));
        }