Пример #1
0
        public string processFragment(string fragment, string csv)
        {
            usernames = csvToCollection(csv);
            XDocument document = new TestRig()
                .WithFixture(this)
                .ProcessFragment(fragment)
                .GetXDocument();

            var result = String.Empty;

            var table = document.Descendants("table").ToList()[0];
            var rows = table.Elements("tr");

            for (int index = 1; index < rows.Count(); index++)
            {
                var row = rows.ToArray()[index];
                if (!String.IsNullOrEmpty(result))
                {
                    result += ", ";
                }
                result += categorize(row);
            }

            return result;
        }
        public bool fragmentSucceeds(string fragment)
        {
            ProcessingResult result = new TestRig()
                .WithFixture(this)
                .ProcessFragment(fragment);

            return result.IsSuccess && result.SuccessCount > 0;
        }
 public void process(String fragment)
 {
     TestRig = new TestRig();
     this.ConfigureTestRig();
     ProcessingResult = TestRig.WithFixture(this)
       .WithExtension(this.Extension)
       .ProcessFragment(fragment);
 }
        public string process(string snippet)
        {
            long successCount = new TestRig()
                .WithStubbedEvaluationResult("Fred")
                .ProcessFragment(snippet)
                .SuccessCount;

            return successCount == 1 ? snippet : "Did not work";
        }
 public string process(string html)
 {
     var rootElement = new TestRig()
                             .Process(html)
                             .GetXDocument()
                             .Root;
     RemoveIrrelevantElements(rootElement);
     return rootElement.ToString(SaveOptions.DisableFormatting);
 }
 public string process(string html)
 {
     var rootElement = new TestRig()
                             .Process(html)
                             .GetDocument()
                             .getRootElement();
     RemoveIrrelevantElements(rootElement);
     return rootElement.toXML();
 }
        public string process(string inputFragment)
        {
            var document = new TestRig()
                                .WithFixture(this)
                                .ProcessFragment(inputFragment)
                                .GetXDocument();

            var table = document.Element("html").Element("body").Element("fragment").Element("table");

            return table.ToString().Replace("\u00A0", "&#160;");
        }
Пример #8
0
        public string getOutputFragment(string inputFragment)
        {
            var document = new TestRig()
                                .WithFixture(this)
                                .ProcessFragment(inputFragment)
                                .GetDocument();

            var tables = document.query("//table").get(0);

            return tables.toXML().Replace("\u00A0", "&#160;");
        }
 public string Process(string fixtureNameSpace, string fixtureClassName)
 {
     var fullClassName = string.Concat(fixtureNameSpace, ".", fixtureClassName);
     var fixtureType = Type.GetType(fullClassName);
     var fixture = Activator.CreateInstance(fixtureType);
     var testRig = new TestRig();
     testRig.Configuration = Configuration;
     var processingResult = testRig
         .WithFixture(fixture)
         .ProcessFragment("<p>anything..</p>");
     return processingResult.GetRootElement().GetAttributeValue(FakeExtensionBase.FakeExtensionAttrName);
 }
Пример #10
0
 public object countsFromExecutingSnippetWithSimulatedEvaluationResult(string snippet, string simulatedResult)
 {
     TestRig harness = new TestRig();
     if (simulatedResult.Equals("(An exception)"))
     {
         harness.WithStubbedEvaluationResult(new Exception("simulated exception"));
     }
     else
     {
         harness.WithStubbedEvaluationResult(simulatedResult);
     }
     return harness.ProcessFragment(snippet);
 }
Пример #11
0
        public string process(string snippet)
        {
            ProcessingResult r = new TestRig()
                                        .WithFixture(this)
                                        .ProcessFragment(snippet);

            if (r.ExceptionCount != 0)
            {
                return "exception";
            }

            return r.SuccessOrFailureInWords();
        }
 public string Process(string fixtureNameSpace, string fixtureClassName)
 {
     var fullClassName = string.Concat(fixtureNameSpace, ".", fixtureClassName);
     var fixtureType = Type.GetType(fullClassName);
     var fixture = Activator.CreateInstance(fixtureType);
     var testRig = new TestRig();
     testRig.Configuration = Configuration;
     var processingResult = testRig
         .WithFixture(fixture)
         .ProcessFragment("<p>anything..</p>");
     var extensionNamesString = processingResult.GetRootElement().GetAttributeValue(FakeExtensionBase.FakeExtensionAttrName);
     var extensionNames = extensionNamesString.Split(',').Select(extensionName => extensionName.Trim()).ToList();
     extensionNames.Sort();
     return String.Join(", ", extensionNames.ToArray());
 }
Пример #13
0
        public string markAsException(string fragment, string expression, string errorMessage)
        {
            var exception = new StackTraceSettingException(errorMessage);
            exception.StackTraceElements.AddRange(stackTraceElements);

            var document = new TestRig()
                                .ProcessFragment(fragment)
                                .GetXDocument();

            var element = new Element(document.Descendants("p").ToArray()[0]);

            new ExceptionRenderer().ExceptionCaught(new ExceptionCaughtEvent(exception, element, expression));

            return element.ToXml();
        }
Пример #14
0
        public string getOutputFragment(string inputFragment)
        {
            var document = new TestRig()
                                .WithFixture(this)
                                .ProcessFragment(inputFragment)
                                .GetXDocument();

            var tables = document.Descendants("table");

            foreach (var table in tables)
            {
                // stops loop after first entry, simulating the java code.
                return table.ToString().Replace("\u00A0", "&#160;");
            }

            return String.Empty;
        }
        public string markAsException(string fragment, string expression, string errorMessage)
        {
            var exception = new StackTraceSettingException(errorMessage);
            exception.StackTraceElements.AddRange(stackTraceElements);

            var document = new TestRig()
                                .ProcessFragment(fragment)
                                .GetXDocument();

            var element = document.Descendants("p").ToArray()[0];

            var eventArgs = new ExceptionCaughtEventArgs { Exception = exception, Expression = expression, Element = new Element(element) };
            new ExceptionRenderer().ExceptionCaughtEventHandler(this, eventArgs);

            //return element.ToString(SaveOptions.DisableFormatting);
            return element.ToString();
        }
 public Result process(string fragment)
 {
     ProcessingResult r = new TestRig()
         .WithFixture(this)
         .ProcessFragment(fragment);
     
     Result result = new Result();
     result.successCount = r.SuccessCount;
     result.failureCount = r.FailureCount;
     result.exceptionCount = r.ExceptionCount;
     
     // TODO - repair this
     var lastEvent = r.GetLastAssertEqualsFailureEvent();
     if (lastEvent != null)
     {
         result.lastActualValue = lastEvent.getActual();
         result.lastExpectedValue = lastEvent.getExpected();
     }
     
     return result;
 }
Пример #17
0
        public string processFragment(string fragment, string csv)
        {
            usernames = csvToCollection(csv);
            Document document = new TestRig()
                .WithFixture(this)
                .ProcessFragment(fragment)
                .GetDocument();

            var result = String.Empty;

            var table = (Element) document.getRootElement().query("//table").get(0);
            var rows = table.query(".//tr");
            for (int i = 1; i < rows.size(); i++) {
                if (!result.Equals("")) {
                    result += ", ";
                }
                result += categorize((Element)rows.get(i));
            }

            return result;
        }
Пример #18
0
 public void process(string fragment)
 {
     ProcessingResult r = new TestRig()
         .WithFixture(this)
         .ProcessFragment(fragment);
 }