示例#1
0
        private ParsedScrubfuTag GetParsedTagFromTagString(string tagName, string tagOptions, int?columnArrayIndex, int lineNum)
        {
            ParsedScrubfuTag tag = null;

            switch (tagName.ToUpper())
            {
            case "MA":
            case "MASK":
                tag = new MaskTag(tagOptions, columnArrayIndex);
                break;

            case "RE":
            case "REPLACE":
                tag = new ReplaceTag(tagOptions, columnArrayIndex);
                break;

            case "RA":
            case "RANDOM":
                tag = new RandomTag(tagOptions, columnArrayIndex);
                break;

            case "FZ":
            case "FUZZ":
                tag = new FuzzTag(tagOptions, columnArrayIndex);
                break;
            }

            if (tag != null && !tag.ValidateTag())
            {
                LogWarning(string.Format("A potentially invalidly formatted Scrubfu tag was found while processing line {0}.", lineNum));
                tag = null;
            }

            return(tag);
        }
示例#2
0
        public void Apply_EmptyString_EmptyReturned()
        {
            var TagOptions = string.Empty;
            var text       = string.Empty;

            var    maskTag = new MaskTag(TagOptions);
            string result  = maskTag.Apply(text);

            Assert.True((result != null && result.Length == 0), "Empty input text should return empty output text");
        }
示例#3
0
        public void Apply_EmailStringWithSingleQuotesOnStrings_ReturnsMaskedEmailString3()
        {
            // This test caters for mask rules in accordance with the test input
            var TagOptions = "0,0;.;'@','.'";
            var text       = "*****@*****.**";

            var maskTag = new MaskTag(TagOptions);

            string result = maskTag.Apply(text);

            Match match = Regex.Match(result, @"\.{11}@.{9}", RegexOptions.Singleline);

            Assert.True(match.Success, "Mask logic should work according to the mask Tag rules");
        }
示例#4
0
        public void Apply_EmailStringWithSingleQuotesOnBiggerStringsWithPreOrPostAndSingleQuote_ReturnsMaskedEmailString()
        {
            // This test caters for mask rules in accordance with the test input
            var TagOptions = "3,2;#;'ma','.','com',''th','@'";
            var text       = "peter.smi'*****@*****.**";

            var maskTag = new MaskTag(TagOptions);

            string result = maskTag.Apply(text);

            Match match = Regex.Match(result, "pet#{2}.#{3}'th@#ma#{2}.#om", RegexOptions.Singleline);

            Assert.True(match.Success, "Mask logic should work according to the mask tag rules");
        }
示例#5
0
        public void Apply_EmailStringWithoutSingleQuotesOnStrings_ReturnsMaskedEmailString2()
        {
            // This test caters for mask rules in accordance with the test input
            var TagOptions = "1,0;*;@,.";
            var text       = "*****@*****.**";

            var maskTag = new MaskTag(TagOptions);

            string result = maskTag.Apply(text);

            Match match = Regex.Match(result, @"[a-z]{1}\*{4}.\*{5}@\*{5}.\*{3}", RegexOptions.Singleline);

            Assert.True(match.Success, "Mask logic should work according to the mask tag rules");
        }
示例#6
0
        public void Apply_NonMaskOption_ExceptionReturned(Type type)
        {
            var TagOptions      = string.Empty;
            var text            = "mock text";
            var returnException = new Exception();

            dynamic nonFuzzOption = Activator.CreateInstance(type);
            var     maskTag       = new MaskTag(TagOptions);

            try
            {
                maskTag.Apply(text, nonFuzzOption);
            }
            catch (Exception ex)
            {
                returnException = ex;
            }

            Assert.True((returnException.GetType().Equals(new NoOptionsSuppliedException().GetType())), "");
        }