Пример #1
0
 public static IFeatureResult GetFeatureResultWithoutDescriptionNorLabelNorDetails()
 {
     return(Mocks.CreateFeatureResult("My feature", null, null,
                                      Mocks.CreateScenarioResult("name", null, _startDate.AddSeconds(1), TimeSpan.FromMilliseconds(25), null,
                                                                 Mocks.CreateStepResult(1, "step1", ResultStatus.Passed, _startDate.AddSeconds(2), TimeSpan.FromMilliseconds(20)),
                                                                 Mocks.CreateStepResult(2, "step2", ResultStatus.Ignored, _startDate.AddSeconds(3), TimeSpan.FromMilliseconds(5)))));
 }
        public void Should_add_results()
        {
            var featureResult = Mocks.CreateFeatureResult(string.Empty, string.Empty, string.Empty);

            _subject.AddResult(featureResult);

            Assert.That(_subject.Results, Is.EqualTo(new[] { featureResult }));
        }
        public void Should_add_and_save_results()
        {
            var feature = Mocks.CreateFeatureResult("name", "description", "label");

            _subject.AddFeature(feature);
            _subject.Finished();
            _writer.AssertWasCalled(w => w.Save(feature));
        }
Пример #4
0
        public static IFeatureResult[] GetMultipleFeatureResults()
        {
            var feature1 = Mocks.CreateFeatureResult("My feature", null, null,
                                                     Mocks.CreateScenarioResult("scenario1", null, _startDate.AddSeconds(1), TimeSpan.FromMilliseconds(20), new[] { "categoryA" },
                                                                                Mocks.CreateStepResult(1, "step1", ResultStatus.Passed, _startDate.AddSeconds(2), TimeSpan.FromMilliseconds(20))));

            var feature2 = Mocks.CreateFeatureResult("My feature2", null, null,
                                                     Mocks.CreateScenarioResult("scenario1", null, _startDate.AddSeconds(4), TimeSpan.FromMilliseconds(20), new[] { "categoryB" },
                                                                                Mocks.CreateStepResult(1, "step1", ResultStatus.Passed, _startDate.AddSeconds(5), TimeSpan.FromMilliseconds(20))));

            return(new[] { feature1, feature2 });
        }
Пример #5
0
        public static IFeatureResult GetFeatureResultWithDescription()
        {
            return(Mocks.CreateFeatureResult("My feature", string.Format("My feature{0}long description", Environment.NewLine), "Label 1",
                                             Mocks.CreateScenarioResult("name", "Label 2", _startDate.AddSeconds(1), new TimeSpan(0, 0, 1, 2, 100), new[] { "categoryA" },
                                                                        Mocks.CreateStepResult(1, ResultStatus.Passed)
                                                                        .WithTimes(_startDate.AddSeconds(2), new TimeSpan(0, 1, 1))
                                                                        .WithStepNameDetails("call step1 \"arg1\"", "step1 \"{0}\"", "call", "arg1")
                                                                        .WithComments(@"multiline
comment", "comment 2"),
                                                                        Mocks.CreateStepResult(2, "step2", ResultStatus.Ignored, _startDate.AddSeconds(3), new TimeSpan(0, 0, 0, 1, 100), "Not implemented yet")),

                                             Mocks.CreateScenarioResult("name2", null, _startDate.AddSeconds(4), new TimeSpan(0, 0, 0, 2, 157), new[] { "categoryB", "categoryC" },
                                                                        Mocks.CreateStepResult(1, "step3", ResultStatus.Bypassed, _startDate.AddSeconds(5), new TimeSpan(0, 0, 0, 2, 107), "bypass reason"),
                                                                        Mocks.CreateStepResult(2, "step4", ResultStatus.Failed, _startDate.AddSeconds(6), new TimeSpan(0, 0, 0, 0, 50), string.Format("  Expected: True{0}  But was: False", Environment.NewLine)),
                                                                        Mocks.CreateStepResult(3, "step5", ResultStatus.NotRun))));
        }
Пример #6
0
        public void Should_save_results_to_file_even_if_directory_does_not_exist()
        {
            const string expectedText = "some expected text";
            var          feature      = Mocks.CreateFeatureResult("name", "description", "label");

            try
            {
                _formatter.Stub(f => f.Format(Arg <IFeatureResult[]> .Matches(l => l.Contains(feature)))).Return(expectedText);
                _subject.Save(feature);
                Assert.That(File.ReadAllText(_filePath), Is.EqualTo(expectedText));
            }
            finally
            {
                File.Delete(_filePath);
                Directory.Delete(_dirPath);
            }
        }
        public void Should_add_result_be_thread_safe()
        {
            var results = new List <IFeatureResult>();

            for (int i = 0; i < 1000; ++i)
            {
                results.Add(Mocks.CreateFeatureResult(
                                i.ToString(CultureInfo.InvariantCulture),
                                i.ToString(CultureInfo.InvariantCulture),
                                i.ToString(CultureInfo.InvariantCulture)));
            }

            results.AsParallel().ForAll(r => _subject.AddResult(r));

            foreach (var result in results)
            {
                Assert.That(_subject.Results.Contains(result), string.Format("Result {0} is missing", result.Name));
            }
        }
Пример #8
0
 public IFeatureResult Build()
 {
     return(Mocks.CreateFeatureResult(Name, "descr", "label", _scenarios.Select(s => s.Build()).ToArray()));
 }