public void You_cannot_log_a_behavior_without_a_started_operation() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); Assert.Throws <InvalidOperationException>(() => sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION")); } }
public void You_cannot_log_a_behavior_when_the_last_operation_has_been_logged_as_finished() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); sut.OperationStarted(new FakeOperation()); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); Assert.Throws <InvalidOperationException>(() => sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION")); } }
public void Behaviors_are_logged_nested_between_braces() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); sut.OperationStarted(new FakeOperation()); sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION"); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); Assert.Equal($"FakeOperation {{{NL} FakeOperationBehavior: DESCRIPTION{NL}}} [duration: 0ms]", sw.ToString()); } }
public void Behaviors_are_correctly_indented_after_a_sibling_operation() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); sut.OperationStarted(new FakeOperation()); sut.OperationStarted(new FakeOperation()); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION"); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); Assert.Equal($"FakeOperation {{{NL} FakeOperation [duration: 0ms]{NL}{NL} FakeOperationBehavior: DESCRIPTION{NL}}} [duration: 0ms]", sw.ToString()); } }
public void You_cannot_log_a_behavior_when_the_last_operation_has_been_logged_as_finished() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); sut.OperationStarted(new FakeOperation()); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); Assert.Throws<InvalidOperationException>(() => sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION")); } }
public void You_cannot_log_a_behavior_without_a_started_operation() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); Assert.Throws<InvalidOperationException>(() => sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION")); } }
public void Behaviors_are_correctly_indented_after_a_sibling_operation() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); sut.OperationStarted(new FakeOperation()); sut.OperationStarted(new FakeOperation()); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION"); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); Assert.Equal($"FakeOperation {{{NL} FakeOperation [duration: 0ms]{NL}{NL} FakeOperationBehavior: DESCRIPTION{NL}}} [duration: 0ms]", sw.ToString()); } }
public void Behaviors_are_logged_nested_between_braces() { using (var sw = new StringWriter()) { var sut = new TextWriterWorkflowLogger(sw); sut.OperationStarted(new FakeOperation()); sut.BehaviorWasApplied(new FakeOperation(), new FakeOperationBehavior(), "DESCRIPTION"); sut.OperationFinished(new FakeOperation(), TimeSpan.Zero); Assert.Equal($"FakeOperation {{{NL} FakeOperationBehavior: DESCRIPTION{NL}}} [duration: 0ms]", sw.ToString()); } }