Beispiel #1
0
        public static string Swap(string code)
        {
            var regex     = new Regex("{[^{}]*}");
            var innerCode = code;

            var matches        = regex.Match(innerCode);
            var stopTheMadness = 5;
            var ididsomething  = true;

            while (matches.Success && stopTheMadness > 0 && ididsomething)
            {
                stopTheMadness--;
                ididsomething = false;

                foreach (Group group in matches.Groups)
                {
                    var textToReplace = group.Value;

                    var textToSwap = textToReplace.TrimAlphaOmega();

                    try
                    {
                        var replaceResult = FieldAid.ObjectCreator <string>(textToSwap);

                        // we didn't actually do anything.
                        // don't replace the tag.
                        if (textToSwap == replaceResult)
                        {
                            continue;
                        }

                        innerCode     = innerCode.Replace(textToReplace, replaceResult);
                        ididsomething = true;
                    }
                    // ReSharper disable once EmptyGeneralCatchClause
                    // Test might be checking for output containing '{' and '}' don't break or crash.
                    // Maybe, consider logging result.
                    catch (Exception)
                    { }
                }

                matches = regex.Match(innerCode);
            }

            return(innerCode);
        }
Beispiel #2
0
 public int this[string index]
 {
     get { return(FieldAid.ObjectCreator <Int32>(index)); }
 }
Beispiel #3
0
 public string this[string index]
 {
     get { return(FieldAid.ObjectCreator <string>(index)); }
 }
Beispiel #4
0
        public void WhenGoesUpTheHill(string personTag)
        {
            var person = FieldAid.ObjectCreator <Person>(personTag);

            person.Address = "Top of Hill";
        }
Beispiel #5
0
        public void ThenVerifyIs(string actual, string expected)
        {
            var actualFirstName = FieldAid.ObjectCreator <string>(actual);

            FieldAid.ObjectComparer(actualFirstName, expected);
        }
Beispiel #6
0
        public void ThenDoExpressionForString(string expression, string expected)
        {
            var actual = FieldAid.ObjectCreator <string>(expression);

            FieldAid.ObjectComparer(actual, expected);
        }