示例#1
0
        public void Apply_EmptyString_EmptyReturned()
        {
            var TagOptions = string.Empty;
            var text       = string.Empty;

            var    randomTag = new RandomTag(TagOptions);
            string result    = randomTag.Apply(text);

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

            var randomTag = new RandomTag(TagOptions);

            string result = randomTag.Apply(text);

            Match match = Regex.Match(result, @"[a-z]{4}\.[a-z]{2}\.[a-z]\.[a-z]{4}!", RegexOptions.Singleline);

            Assert.True(match.Success, "Fuzz logic should work according to the random tag rules");
        }
示例#3
0
        public void Apply_Numerics_ReturnsRandomizedNumber()
        {
            // This test caters for mask rules in accordance with the test input
            var TagOptions = "";
            var text       = "+NNN(NNN) NNN-NNNN";

            var randomTag = new RandomTag(TagOptions);

            string result = randomTag.Apply(text);

            Match match = Regex.Match(result, @"\+[0-9]{3}\([0-9]{3}\) [0-9]{3}-[0-9]{4}", RegexOptions.Singleline);

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

            dynamic nonRandomOption = Activator.CreateInstance(type);
            var     randomTag       = new RandomTag(TagOptions);

            try
            {
                randomTag.Apply(text, nonRandomOption);
            }
            catch (Exception ex)
            {
                returnException = ex;
            }

            Assert.True((returnException.GetType().Equals(new NoOptionsSuppliedException().GetType())), "Exception should be thrown if a non RandomOption is supplied.");
        }