Пример #1
0
 private static void AssertTestIsProperlyFormatted(RawTest rawTest)
 {
     Assert.IsFalse(string.IsNullOrEmpty(rawTest.Title));
     Assert.AreNotEqual(0, rawTest.Headers.Count);
     rawTest.Headers.ForEach(header => Assert.IsFalse(string.IsNullOrEmpty(header)));
     Assert.AreNotEqual(0, rawTest.DataRows);
     rawTest.DataRows.ForEach(dataRow=> AssertDataRowFilled(dataRow, rawTest.Headers.Count));
 }
Пример #2
0
        public ScenarioResult Test(RawTest[] rawTests, IResultsWriter resultsWriter)
        {
            var results = new ScenarioResult(name);
            resultsWriter.Begin(results);

            UserCache cache = new UserCache();
            foreach (RawTest rawTest in rawTests)
            {
                var realTest = rawTest.CreateRealTest(assemblies, cache);
                results.Add(realTest.Test(resultsWriter));
            }
            resultsWriter.End(results);
            return results;
        }
Пример #3
0
 public bool Equals(RawTest other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Title, Title) && Equals(other.Headers, Headers) && Equals(other.DataRows, DataRows);
 }
Пример #4
0
            private void AddRepeatedInstructions(IInstructionParent parent, RawTest rawTest, Type targetType)
            {
                parent.AddInstruction(new NextDataRow(rawTest.DataRows));

                List<string> trimmedHeaders = rawTest.Headers.ConvertAll(header => NormalizeHeader(header));
                List<IInstruction> instructions = (testStyle == TestStyle.Input)
                                                      ? CreateInputInstructions(trimmedHeaders, targetType)
                                                      : CreateOutputInstructions(trimmedHeaders, targetType);
                instructions.ForEach(parent.AddInstruction);
            }
Пример #5
0
 private void AddAutoExecutionWhereApplicable(RawTest rawTest, Type targetType)
 {
     //todo: duplication
     List<string> trimmedHeaders = rawTest.Headers.ConvertAll(input => NormalizeHeader(input));
     //todo: lowercase and +? action format assumptions; also string literal
     if (IsAutoExecuteFixture(targetType) && !trimmedHeaders.Contains("autoexecute?"))
     {
         rawTest.Headers.Add("autoexecute?");
         if (rawTest.DataRows.Count == 0) { rawTest.DataRows.Add(new Row()); }
         rawTest.DataRows.ForEach(row1 => row1.AddCell(new Cell("True")));
     }
 }
Пример #6
0
            public RealTest CreateRealTestFrom(RawTest rawTest)
            {
                var test = new RealTest(rawTest.Title, rawTest.Headers, userCache);

                // title is one of: (1) Class.Name (2) cache entry=> (3) cache entry=>Adapter.Class.Name
                Type targetType = AddInstructionsFromTitle(test, rawTest.Title);

                testStyle = DetermineTestType(targetType, rawTest.Headers);
                if (IsOutputTest)
                {
                    ManageActualRowEnumeration(test, targetType);
                }

                AddAutoExecutionWhereApplicable(rawTest, targetType);

                // instruction to repeat over every row of data
                IInstructionParent repeatOverRows = AddRepeatOverRows(test, rawTest.DataRows);

                // instructions repeated for each row of data
                AddRepeatedInstructions(repeatOverRows, rawTest, targetType);

                return test;
            }
Пример #7
0
 public void Test(string scenarioName, RawTest[] rawTests, IResultsWriter resultsWriter)
 {
     var scenario = new Scenario(scenarioName, assemblies);
     scenario.Test(rawTests, resultsWriter);
 }