/// <summary> /// Determines whether the specified <see cref="ExceptionCentricTestSpecification" /> is equal to this instance. /// </summary> /// <param name="other">The <see cref="ExceptionCentricTestSpecification" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="ExceptionCentricTestSpecification" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> protected bool Equals(ExceptionCentricTestSpecification other) { return (Equals(_givens, other._givens) && Equals(_when, other._when) && Equals(_throws, other._throws)); }
void WriteThrows(ExceptionCentricTestSpecification specification) { _writer.WriteLine("Throws"); _writer.Indent++; _writer.WriteLine("[{0}] {1}", specification.Throws.GetType().Name, specification.Throws.Message); _writer.Indent--; }
void WriteGivens(ExceptionCentricTestSpecification specification) { if (specification.Givens.Length == 0) return; _writer.WriteLine("Given"); WriteFacts(specification.Givens); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionCentricTestResult"/> class. /// </summary> /// <param name="specification">The specification.</param> /// <param name="state">The state.</param> /// <param name="actualException">The actual exception.</param> /// <param name="actualEvents">The actual events.</param> internal ExceptionCentricTestResult(ExceptionCentricTestSpecification specification, TestResultState state, Optional<Exception> actualException, Optional<Fact[]> actualEvents) { _specification = specification; _state = state; _actualException = actualException; _actualEvents = actualEvents; }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionCentricTestResult"/> class. /// </summary> /// <param name="specification">The specification.</param> /// <param name="state">The state.</param> /// <param name="actualException">The actual exception.</param> /// <param name="actualEvents">The actual events.</param> internal ExceptionCentricTestResult(ExceptionCentricTestSpecification specification, TestResultState state, Optional <Exception> actualException, Optional <Fact[]> actualEvents) { _specification = specification; _state = state; _actualException = actualException; _actualEvents = actualEvents; }
public void UsingDefaultConstructorReturnsInstanceWithExpectedProperties(Tuple <string, object>[] givens, object when, Exception throws) { var sut = new ExceptionCentricTestSpecification(givens, when, throws); Assert.That(sut.Givens, Is.EquivalentTo(givens)); Assert.That(sut.When, Is.SameAs(when)); Assert.That(sut.Throws, Is.SameAs(throws)); }
public void FailReturnsExpectedResult() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); var result = sut.Fail(); Assert.That(result.Specification, Is.SameAs(sut)); Assert.That(result.Passed, Is.False); Assert.That(result.Failed, Is.True); Assert.That(result.But, Is.EqualTo(Optional<Exception>.Empty)); }
void WriteGivens(ExceptionCentricTestSpecification specification) { if (specification.Givens.Length == 0) { return; } _writer.WriteLine("Given"); WriteEvents(specification.Givens); }
public void FailReturnsExpectedResult() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); var result = sut.Fail(); Assert.That(result.Specification, Is.SameAs(sut)); Assert.That(result.Passed, Is.False); Assert.That(result.Failed, Is.True); Assert.That(result.But, Is.EqualTo(Optional <Exception> .Empty)); }
public void FailWithActualExceptionReturnsExpectedResult() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); var actual = new Exception(); var result = sut.Fail(actual); Assert.That(result.Specification, Is.SameAs(sut)); Assert.That(result.Passed, Is.False); Assert.That(result.Failed, Is.True); Assert.That(result.ButException, Is.EqualTo(new Optional <Exception>(actual))); }
public void WriteExceptionCentricTestSpecificationResultsInExpectedOutput( ExceptionCentricTestSpecification specification, string result) { using (var writer = new StringWriter()) { var sut = new TestSpecificationTextWriter(writer); sut.Write(specification); Assert.That(writer.ToString(), Is.EqualTo(result)); } }
public void FailWithActualExceptionReturnsExpectedResult() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); var actual = new Exception(); var result = sut.Fail(actual); Assert.That(result.Specification, Is.SameAs(sut)); Assert.That(result.Passed, Is.False); Assert.That(result.Failed, Is.True); Assert.That(result.ButException, Is.EqualTo(new Optional<Exception>(actual))); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionCentricTestResult"/> class. /// </summary> /// <param name="specification">The specification.</param> /// <param name="state">The state.</param> /// <param name="actualException">The actual exception.</param> /// <param name="actualEvents">The actual events.</param> internal ExceptionCentricTestResult(ExceptionCentricTestSpecification specification, TestResultState state, Exception actualException = null, Tuple<string, object>[] actualEvents = null) { _specification = specification; _state = state; _actualException = actualException == null ? Optional<Exception>.Empty : new Optional<Exception>(actualException); _actualEvents = actualEvents == null ? Optional<Tuple<string, object>[]>.Empty : new Optional<Tuple<string, object>[]>(actualEvents); }
/// <summary> /// Initializes a new instance of the <see cref="ExceptionCentricTestResult"/> class. /// </summary> /// <param name="specification">The specification.</param> /// <param name="state">The state.</param> /// <param name="actualException">The actual exception.</param> /// <param name="actualEvents">The actual events.</param> internal ExceptionCentricTestResult(ExceptionCentricTestSpecification specification, TestResultState state, Exception actualException = null, Tuple <string, object>[] actualEvents = null) { _specification = specification; _state = state; _actualException = actualException == null ? Optional <Exception> .Empty : new Optional <Exception>(actualException); _actualEvents = actualEvents == null ? Optional <Tuple <string, object>[]> .Empty : new Optional <Tuple <string, object>[]>(actualEvents); }
public void FailWithActualEventsReturnsExpectedResult() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); var actual = new[] { new Tuple <string, object>(Model.Identifier1, new object()) }; var result = sut.Fail(actual); Assert.That(result.Specification, Is.SameAs(sut)); Assert.That(result.Passed, Is.False); Assert.That(result.Failed, Is.True); Assert.That(result.Buts, Is.EqualTo(new Optional <Tuple <string, object>[]>(actual))); Assert.That(result.But, Is.EqualTo(Optional <Exception> .Empty)); }
public void FailWithActualEventsReturnsExpectedResult() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); var actual = new[] {new Tuple<string, object>(Model.Identifier1, new object())}; var result = sut.Fail(actual); Assert.That(result.Specification, Is.SameAs(sut)); Assert.That(result.Passed, Is.False); Assert.That(result.Failed, Is.True); Assert.That(result.Buts, Is.EqualTo(new Optional<Tuple<string, object>[]>(actual))); Assert.That(result.But, Is.EqualTo(Optional<Exception>.Empty)); }
public void DoesEqualItself() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); Assert.That(sut.Equals(sut), Is.True); }
public void UsingDefaultConstructorReturnsInstanceWithExpectedProperties(Tuple<string, object>[] givens, object when, Exception throws) { var sut = new ExceptionCentricTestSpecification(givens, when, throws); Assert.That(sut.Givens, Is.EquivalentTo(givens)); Assert.That(sut.When, Is.SameAs(when)); Assert.That(sut.Throws, Is.SameAs(throws)); }
void WriteWhen(ExceptionCentricTestSpecification specification) { _writer.WriteLine("When"); WriteMessage(specification.When); }
public void DoesNotEqualNull() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); Assert.That(sut.Equals(null), Is.False); }
/// <summary> /// Writes the specified test specification. /// </summary> /// <param name="specification">The test specification to write.</param> public void Write(ExceptionCentricTestSpecification specification) { WriteGivens(specification); WriteWhen(specification); WriteThrows(specification); }
public void DoesNotEqualObjectOfOtherType() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); Assert.That(sut.Equals(new object()), Is.False); }
public void FailWithNullExceptionThrows() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); Assert.Throws<ArgumentNullException>(() => { var _ = sut.Fail((Exception) null); }); }
/// <summary> /// Determines whether the specified <see cref="ExceptionCentricTestSpecification" /> is equal to this instance. /// </summary> /// <param name="other">The <see cref="ExceptionCentricTestSpecification" /> to compare with this instance.</param> /// <returns> /// <c>true</c> if the specified <see cref="ExceptionCentricTestSpecification" /> is equal to this instance; otherwise, <c>false</c>. /// </returns> protected bool Equals(ExceptionCentricTestSpecification other) { return Equals(_givens, other._givens) && Equals(_when, other._when) && Equals(_throws, other._throws); }
public void FailWithNullEventsThrows() { var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception); Assert.Throws <ArgumentNullException>(() => { var _ = sut.Fail((Tuple <string, object>[])null); }); }