public void MultipleStepsTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
            _lifecycle.Fire(tsevt);
            var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
            _lifecycle.Fire(tcsevt);
            _lifecycle.Fire(new StepStartedEvent("step1"));
            _lifecycle.Fire(new StepFinishedEvent());

            Assert.AreEqual(1, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.steps[0].name);
            Assert.AreEqual(status.passed, _lifecycle.StepStorage.Get().Last.Value.steps[0].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[0].stop);

            _lifecycle.Fire(new StepStartedEvent("step2"));
            _lifecycle.Fire(new StepFailureEvent());
            _lifecycle.Fire(new StepFinishedEvent());

            Assert.AreEqual(2, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step2", _lifecycle.StepStorage.Get().Last.Value.steps[1].name);
            Assert.AreEqual(status.broken, _lifecycle.StepStorage.Get().Last.Value.steps[1].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[1].stop);

            _lifecycle.Fire(new StepStartedEvent("step3"));
            _lifecycle.Fire(new StepFinishedEvent());

            Assert.AreEqual(3, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
            Assert.AreEqual("step3", _lifecycle.StepStorage.Get().Last.Value.steps[2].name);
            Assert.AreEqual(status.passed, _lifecycle.StepStorage.Get().Last.Value.steps[2].status);
            Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[2].stop);
        }
 /// <summary>
 /// Updates TestSuiteStartedEvent based on attributes.
 /// <see cref="AllureCSharpCommons.Attributes"/>
 /// </summary>
 /// <param name="evt"></param>
 public void Update(TestSuiteStartedEvent evt)
 {
     _attributes.ForEach(x =>
     {
         if (x.GetType() == typeof (AllureTitleAttribute))
         {
             var attr = (AllureTitleAttribute)x;
             evt.Title = attr.Value;
         }
         else if (x.GetType() == typeof (AllureDescriptionAttribute))
         {
             var attr = (AllureDescriptionAttribute)x;
             evt.Description = attr.Value;
         }
         else if (x.GetType() == typeof(AllureStoriesAttribute))
         {
             var attr = (AllureStoriesAttribute)x;
             evt.Labels = ArraysUtils.AddLabels(evt.Labels, "story", attr.Stories);
         }
         else if (x.GetType() == typeof(AllureFeaturesAttribute))
         {
             var attr = (AllureFeaturesAttribute)x;
             evt.Labels = ArraysUtils.AddLabels(evt.Labels, "feature", attr.Features);
         }
     });
 }
 public void SuiteFinishedTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tfevt = new TestSuiteFinishedEvent(SuiteUid);
     _lifecycle.Fire(tfevt);
     Assert.AreEqual(0, _lifecycle.TestSuiteStorage.Map.Count);
     Assert.False(_lifecycle.TestSuiteStorage.Map.ContainsKey(SuiteUid));
 }
 public void SuiteStartedEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var evt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(evt);
     Assert.AreEqual(1, _lifecycle.TestSuiteStorage.Map.Count);
     Assert.True(_lifecycle.TestSuiteStorage.Map.ContainsKey(SuiteUid));
     Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases);
     Assert.AreEqual("suite42", _lifecycle.TestSuiteStorage.Get(SuiteUid).name);
 }
 public void TestCaseCanceledEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new TestCaseCanceledEvent();
     _lifecycle.Fire(evt);
     Assert.AreEqual(status.canceled, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
     Assert.AreEqual("Test skipped with unknown reason",
         _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
 }
        public void MultipleTestCasesTest()
        {
            _lifecycle = Allure.DefaultLifecycle;
            var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
            _lifecycle.Fire(tsevt);

            var evt = new TestCaseStartedEvent(SuiteUid, "test name1");
            _lifecycle.Fire(evt);
            _lifecycle.Fire(new TestCaseCanceledEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            Assert.IsNull(_lifecycle.TestCaseStorage.Value);
            Assert.AreEqual(1, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
            Assert.AreEqual("test name1", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].name);
            Assert.AreEqual(status.canceled, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
            Assert.AreEqual("Test skipped with unknown reason",
                _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].attachments);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].stop);

            var evt1 = new TestCaseStartedEvent(SuiteUid, "test name2");
            _lifecycle.Fire(evt1);
            _lifecycle.Fire(new TestCasePendingEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            Assert.IsNull(_lifecycle.TestCaseStorage.Value);
            Assert.AreEqual(2, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
            Assert.AreEqual("test name2", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].name);
            Assert.AreEqual(status.pending, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].status);
            Assert.AreEqual("Test not implemented yet",
                _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].failure.message);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].attachments);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[1].stop);

            var evt2 = new TestCaseStartedEvent(SuiteUid, "test name3");
            _lifecycle.Fire(evt2);
            _lifecycle.Fire(new TestCaseFailureEvent());
            _lifecycle.Fire(new TestCaseFinishedEvent());

            Assert.IsNull(_lifecycle.TestCaseStorage.Value);
            Assert.AreEqual(3, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
            Assert.AreEqual("test name3", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].name);
            Assert.AreEqual(status.broken, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].status);
            Assert.AreEqual("Test broken with unknown reason",
                _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].failure.message);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].attachments);
            Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].steps);
            Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[2].stop);
        }
 public void StepFailureEventWithOtherExceptionTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var ssevt = new StepStartedEvent("step1");
     _lifecycle.Fire(ssevt);
     var evt = new StepFailureEvent
     {
         Throwable = new NullReferenceException("other exception")
     };
     _lifecycle.Fire(evt);
     Assert.AreEqual(2, _lifecycle.StepStorage.Get().Count); //Root step + step1
     Assert.AreEqual(status.broken, _lifecycle.StepStorage.Get().Last.Value.status);
 }
 public void TestCaseFailureWithAssertionExceptionAndStackTraceEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new TestCaseFailureEvent
     {
         Throwable = new AssertionException("assertion exception"),
         StackTrace = "stack trace"
     };
     _lifecycle.Fire(evt);
     Assert.AreEqual(status.failed, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
     Assert.AreEqual("assertion exception",
         _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
     Assert.AreEqual("stack trace",
         _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.stacktrace);
 }
 public void TestSuiteStroiesAttributeTest()
 {
     var evt = new TestSuiteStartedEvent("1", "testsuite with title");
     var manager = new AttributeManager(new List<Attribute>
     {
         new AllureStoriesAttribute("Awesome story")
     });
     manager.Update(evt);
     Assert.AreEqual("story", evt.Labels[0].name);
     Assert.AreEqual("Awesome story", evt.Labels[0].value);
 }
 public void TestSuiteSeverityAttributeTest()
 {
     var evt = new TestSuiteStartedEvent("1", "testsuite with severity");
     var manager = new AttributeManager(new List<Attribute>
     {
         new AllureSeverityAttribute(severitylevel.critical)
     });
     manager.Update(evt);
     Assert.IsNull(evt.Labels);
 }
 public void TestSuiteDescriptionAttributeTest()
 {
     var evt = new TestSuiteStartedEvent("1", "testsuite with description");
     var manager = new AttributeManager(new List<Attribute>
     {
         new AllureDescriptionAttribute("Awesome description", descriptiontype.text)
     });
     manager.Update(evt);
     Assert.AreEqual("Awesome description", evt.Description.Value);
     Assert.AreEqual(descriptiontype.text, evt.Description.type);
 }
 public void TestSuiteTitleAttributeTest()
 {
     var evt = new TestSuiteStartedEvent("1", "testsuite with title");
     var manager = new AttributeManager(new List<Attribute>
     {
         new AllureTitleAttribute("Awesome title")
     });
     manager.Update(evt);
     Assert.AreEqual("Awesome title", evt.Title);
 }
 public void TestCasePendingEventWithoutMessageWithExceptionTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new TestCasePendingEvent
     {
         Throwable = new Exception("exception")
     };
     _lifecycle.Fire(evt);
     Assert.AreEqual(status.pending, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
     Assert.AreEqual("exception", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
     Assert.AreEqual("There is no stack trace",
         _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.stacktrace);
 }
 public void TestCasePendingEventWithoutMessageWithoutExceptionTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new TestCasePendingEvent();
     _lifecycle.Fire(evt);
     Assert.AreEqual(status.pending, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
     Assert.AreEqual("Test not implemented yet",
         _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
     Assert.IsNull(_lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.stacktrace);
 }
 public void StepFinishedEventAfterStepFailureEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var ssevt = new StepStartedEvent("step1");
     _lifecycle.Fire(ssevt);
     var sfevt = new StepFailureEvent
     {
         Throwable = new NullReferenceException("other exception")
     };
     _lifecycle.Fire(sfevt);
     var evt = new StepFinishedEvent();
     _lifecycle.Fire(evt);
     Assert.AreEqual(1, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
     Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.steps[0].name);
     Assert.AreEqual(status.broken, _lifecycle.StepStorage.Get().Last.Value.steps[0].status);
     Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[0].stop);
 }
 public void TestCaseFinishedEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new TestCaseFinishedEvent();
     _lifecycle.Fire(evt);
     Assert.IsNull(_lifecycle.TestCaseStorage.Value);
     Assert.AreEqual(1, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases.Length);
     Assert.AreEqual("test name", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].name);
     Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure);
     Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].attachments);
     Assert.AreEqual(null, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].steps);
     Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].stop);
 }
 public void TestSuiteAttributesTest()
 {
     var evt = new TestSuiteStartedEvent("1", "testsuite with title");
     var manager = new AttributeManager(new List<Attribute>
     {
         new AllureTitleAttribute("Awesome title"),
         new AllureDescriptionAttribute("Awesome description", descriptiontype.text),
         new AllureSeverityAttribute(severitylevel.critical),
         new AllureFeaturesAttribute("Awesome feature", "Another awesome feature", "Awesome feature2", "New awesome feature"),
         new AllureStoriesAttribute("Awesome story", "Another awesome story", "Awesome story2", "New awesome story")
     });
     manager.Update(evt);
     Assert.AreEqual("Awesome title", evt.Title);
     Assert.AreEqual("Awesome description", evt.Description.Value);
     Assert.AreEqual(descriptiontype.text, evt.Description.type);
     Assert.AreEqual("feature", evt.Labels[0].name);
     Assert.AreEqual("Awesome feature", evt.Labels[0].value);
     Assert.AreEqual("feature", evt.Labels[1].name);
     Assert.AreEqual("Another awesome feature", evt.Labels[1].value);
     Assert.AreEqual("feature", evt.Labels[2].name);
     Assert.AreEqual("Awesome feature2", evt.Labels[2].value);
     Assert.AreEqual("feature", evt.Labels[3].name);
     Assert.AreEqual("New awesome feature", evt.Labels[3].value);
     Assert.AreEqual("story", evt.Labels[4].name);
     Assert.AreEqual("Awesome story", evt.Labels[4].value);
     Assert.AreEqual("story", evt.Labels[5].name);
     Assert.AreEqual("Another awesome story", evt.Labels[5].value);
     Assert.AreEqual("story", evt.Labels[6].name);
     Assert.AreEqual("Awesome story2", evt.Labels[6].value);
     Assert.AreEqual("story", evt.Labels[7].name);
     Assert.AreEqual("New awesome story", evt.Labels[7].value);
 }
 public void StepStartedEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new StepStartedEvent("step1");
     _lifecycle.Fire(evt);
     Assert.AreEqual(2, _lifecycle.StepStorage.Get().Count); //Root step + step1
     Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.name);
     Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.start);
     Assert.AreEqual(0, _lifecycle.StepStorage.Get().Last.Value.stop);
 }
 public void StepFinishedEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var ssevt = new StepStartedEvent("step1");
     _lifecycle.Fire(ssevt);
     var evt = new StepFinishedEvent();
     _lifecycle.Fire(evt);
     Assert.AreEqual(1, _lifecycle.StepStorage.Get().Last.Value.steps.Length);
     Assert.AreEqual("step1", _lifecycle.StepStorage.Get().Last.Value.steps[0].name);
     Assert.AreEqual(status.passed, _lifecycle.StepStorage.Get().Last.Value.steps[0].status);
     Assert.AreNotEqual(0, _lifecycle.StepStorage.Get().Last.Value.steps[0].stop);
 }
 public void TestCaseStartedEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var evt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(evt);
     Assert.AreEqual(true, _lifecycle.TestCaseStorage.IsValueCreated);
     Assert.AreEqual("test name", _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].name);
     Assert.AreEqual(status.passed, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
     Assert.IsNull(_lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].steps);
     Assert.AreNotEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].start);
     Assert.AreEqual(0, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].stop);
 }
 public void TestCaseFailureWithOtherExceptionEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new TestCaseFailureEvent
     {
         Throwable = new NullReferenceException("null reference exception")
     };
     _lifecycle.Fire(evt);
     Assert.AreEqual(status.broken, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
     Assert.AreEqual("null reference exception",
         _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
 }
 public void TestCaseFailureWithoutExceptionEventTest()
 {
     _lifecycle = Allure.DefaultLifecycle;
     var tsevt = new TestSuiteStartedEvent(SuiteUid, "suite42");
     _lifecycle.Fire(tsevt);
     var tcsevt = new TestCaseStartedEvent(SuiteUid, "test name");
     _lifecycle.Fire(tcsevt);
     var evt = new TestCaseFailureEvent();
     _lifecycle.Fire(evt);
     Assert.AreEqual(status.broken, _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].status);
     Assert.AreEqual("Test broken with unknown reason",
         _lifecycle.TestSuiteStorage.Get(SuiteUid).testcases[0].failure.message);
 }