Ejemplo n.º 1
0
        public void GivenAComplexDatatypeNode_WhenGeneralize_ExceptionWillBeThrown(Base data)
        {
            GeneralizeProcessor processor = new GeneralizeProcessor();
            var node     = ElementNode.FromElement(data.ToTypedElement());
            var settings = new Dictionary <string, object> {
                { "cases", "" }
            };
            var context = new ProcessContext
            {
                VisitedNodes = new HashSet <ElementNode>()
            };

            Assert.Throws <AnonymizerRuleNotApplicableException>(() => processor.Process(node, context, settings));
        }
Ejemplo n.º 2
0
        public void GivenRuntimeInvalidCasesExpressions_WhenGeneralized_ExceptionShouldBeThrown(Base data, string cases)
        {
            var node = ElementNode.FromElement(data.ToTypedElement());

            GeneralizeProcessor processor = new GeneralizeProcessor();
            var context = new ProcessContext
            {
                VisitedNodes = new HashSet <ElementNode>()
            };
            var settings = new Dictionary <string, object> {
                { "cases", cases }
            };

            Assert.Throws <AnonymizerProcessingException>(() => processor.Process(node, context, settings));
        }
Ejemplo n.º 3
0
        public void GivenANode_WhenGeneralizedWithConflictSettings_GeneralizedNodeShouldBeReturned(Base data, object target, string otherValues = "redact")
        {
            var node = ElementNode.FromElement(data.ToTypedElement());

            GeneralizeProcessor processor = new GeneralizeProcessor();
            var context = new ProcessContext
            {
                VisitedNodes = new HashSet <ElementNode>()
            };
            var settings = CreateConflictSettings(otherValues);

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

            Assert.True(processResult.IsGeneralized);
            Assert.Equal(target, Convert.ToInt32(node.Value));
        }
Ejemplo n.º 4
0
        public void GivenADateTimeNode_WhenGeneralizedWithRangeMapping_GeneralizedNodeShouldBeReturned(Base data, object target, string otherValues = "redact")
        {
            var node = ElementNode.FromElement(data.ToTypedElement());

            GeneralizeProcessor processor = new GeneralizeProcessor();
            var context = new ProcessContext
            {
                VisitedNodes = new HashSet <ElementNode>()
            };
            var settings = CreateRangeMappingSettingsForDateTime(otherValues);

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

            Assert.True(processResult.IsGeneralized);
            Assert.Equal(target, node.Value?.ToString());
        }
Ejemplo n.º 5
0
        public void GivenIntegerDecimalComparingCases_WhenGeneralized_GeneralizedNodeShouldBeReturned(Base data, string cases, object target)
        {
            var node = ElementNode.FromElement(data.ToTypedElement());

            GeneralizeProcessor processor = new GeneralizeProcessor();
            var context = new ProcessContext
            {
                VisitedNodes = new HashSet <ElementNode>()
            };
            var settings = new Dictionary <string, object> {
                { "cases", cases }
            };

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

            Assert.True(processResult.IsGeneralized);
            Assert.Equal(target, node.Value);
        }