public void CurrentRunIsNullBeforeStarted() { var repository = new RunDtoRepository(); Assert.Null(repository.CurrentRun); Assert.Throws <NullReferenceException>(() => repository.SetRunName("any name")); Assert.Throws <NullReferenceException>(() => repository.OnTestFinished(new TestRunDto())); Assert.Throws <NullReferenceException>(() => repository.OnRunFinished(DateTime.Now)); }
public void OnRunWithTests() { var start = DateTime.Now; var repository = new RunDtoRepository(); repository.OnRunStarted(_settings, start); repository.OnTestFinished(new TestRunDto(Guid.NewGuid()) { Result = "passed" }); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Errors); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Failures); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Ignored); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Inconclusive); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Success); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Total); Assert.AreEqual(1, repository.CurrentRun.TestsInfo.Count); repository.OnTestFinished(new TestRunDto(Guid.NewGuid()) { Result = "error" }); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Errors); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Failures); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Ignored); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Inconclusive); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Success); Assert.AreEqual(2, repository.CurrentRun.RunSummary.Total); Assert.AreEqual(2, repository.CurrentRun.TestsInfo.Count); repository.OnTestFinished(new TestRunDto(Guid.NewGuid()) { Result = "failed" }); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Errors); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Failures); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Ignored); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Inconclusive); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Success); Assert.AreEqual(3, repository.CurrentRun.RunSummary.Total); Assert.AreEqual(3, repository.CurrentRun.TestsInfo.Count); repository.OnTestFinished(new TestRunDto(Guid.NewGuid()) { Result = "inconclusive" }); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Errors); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Failures); Assert.AreEqual(0, repository.CurrentRun.RunSummary.Ignored); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Inconclusive); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Success); Assert.AreEqual(4, repository.CurrentRun.RunSummary.Total); Assert.AreEqual(4, repository.CurrentRun.TestsInfo.Count); repository.OnTestFinished(new TestRunDto(Guid.NewGuid()) { Result = "ignored" }); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Errors); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Failures); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Ignored); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Inconclusive); Assert.AreEqual(1, repository.CurrentRun.RunSummary.Success); Assert.AreEqual(5, repository.CurrentRun.RunSummary.Total); Assert.AreEqual(5, repository.CurrentRun.TestsInfo.Count); }