void WriteGivens(EventCentricTestSpecification specification)
        {
            if (specification.Givens.Length == 0) return;

            _writer.WriteLine("Given");
            WriteEvents(specification.Givens);
        }
 /// <summary>
 /// Determines whether the specified <see cref="EventCentricTestSpecification" /> is equal to this instance.
 /// </summary>
 /// <param name="other">The <see cref="EventCentricTestSpecification" /> to compare with this instance.</param>
 /// <returns>
 ///   <c>true</c> if the specified <see cref="EventCentricTestSpecification" /> is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 protected bool Equals(EventCentricTestSpecification other)
 {
     return
         (Equals(_givens, other._givens) &&
          Equals(_when, other._when) &&
          Equals(_thens, other._thens));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventCentricTestResult"/> class.
 /// </summary>
 /// <param name="specification">The specification.</param>
 /// <param name="state">The state.</param>
 /// <param name="actualEvents">The actual events.</param>
 /// <param name="actualException">The actual exception.</param>
 internal EventCentricTestResult(EventCentricTestSpecification specification, TestResultState state,
                                 Optional<Fact[]> actualEvents, Optional<Exception> actualException)
 {
     _specification = specification;
     _state = state;
     _actualEvents = actualEvents;
     _actualException = actualException;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventCentricTestResult"/> class.
 /// </summary>
 /// <param name="specification">The specification.</param>
 /// <param name="state">The state.</param>
 /// <param name="actualEvents">The actual events.</param>
 /// <param name="actualException">The actual exception.</param>
 internal EventCentricTestResult(EventCentricTestSpecification specification, TestResultState state,
                                 Optional <Fact[]> actualEvents, Optional <Exception> actualException)
 {
     _specification   = specification;
     _state           = state;
     _actualEvents    = actualEvents;
     _actualException = actualException;
 }
        void WriteGivens(EventCentricTestSpecification specification)
        {
            if (specification.Givens.Length == 0)
            {
                return;
            }

            _writer.WriteLine("Given");
            WriteEvents(specification.Givens);
        }
        public void UsingDefaultConstructorReturnsInstanceWithExpectedProperties(Tuple <string, object>[] givens,
                                                                                 object when,
                                                                                 Tuple <string, object>[] thens)
        {
            var sut = new EventCentricTestSpecification(givens, when, thens);

            Assert.That(sut.Givens, Is.EquivalentTo(givens));
            Assert.That(sut.When, Is.SameAs(when));
            Assert.That(sut.Thens, Is.EquivalentTo(thens));
        }
        public void FailReturnsExpectedResult()
        {
            var sut    = new EventCentricTestSpecification(NoEvents, Message, NoEvents);
            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.Buts, Is.EqualTo(Optional <Exception> .Empty));
            Assert.That(result.But, Is.EqualTo(Optional <Exception> .Empty));
        }
        public void FailReturnsExpectedResult()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);
            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.Buts, Is.EqualTo(Optional<Exception>.Empty));
            Assert.That(result.But, Is.EqualTo(Optional<Exception>.Empty));
        }
        public void WriteEventCentricTestSpecificationResultsInExpectedOutput(
            EventCentricTestSpecification 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 WriteEventCentricTestSpecificationResultsInExpectedOutput(
            EventCentricTestSpecification specification, string result)
        {
            using (var writer = new StringWriter())
            {
                var sut = new TestSpecificationTextWriter(writer);

                sut.Write(specification);

                Assert.That(writer.ToString(), Is.EqualTo(result));
            }
        }
Exemple #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventCentricTestResult"/> class.
 /// </summary>
 /// <param name="specification">The specification.</param>
 /// <param name="state">The state.</param>
 /// <param name="actualEvents">The actual events.</param>
 /// <param name="actualException">The actual exception.</param>
 internal EventCentricTestResult(EventCentricTestSpecification specification, TestResultState state,
                                 Tuple <string, object>[] actualEvents = null, Exception actualException = null)
 {
     _specification = specification;
     _state         = state;
     _actualEvents  = actualEvents == null
                         ? Optional <Tuple <string, object>[]> .Empty
                         : new Optional <Tuple <string, object>[]>(actualEvents);
     _actualException = actualException == null
                            ? Optional <Exception> .Empty
                            : new Optional <Exception>(actualException);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EventCentricTestResult"/> class.
 /// </summary>
 /// <param name="specification">The specification.</param>
 /// <param name="state">The state.</param>
 /// <param name="actualEvents">The actual events.</param>
 /// <param name="actualException">The actual exception.</param>
 internal EventCentricTestResult(EventCentricTestSpecification specification, TestResultState state,
                                 Tuple<string, object>[] actualEvents = null, Exception actualException = null)
 {
     _specification = specification;
     _state = state;
     _actualEvents = actualEvents == null
                         ? Optional<Tuple<string, object>[]>.Empty
                         : new Optional<Tuple<string, object>[]>(actualEvents);
     _actualException = actualException == null
                            ? Optional<Exception>.Empty
                            : new Optional<Exception>(actualException);
 }
        public void FailWithActualEventsReturnsExpectedResult()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            var actual = new[] { new Fact(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.ButEvents, Is.EqualTo(new Optional <Fact[]>(actual)));
            Assert.That(result.ButException, Is.EqualTo(Optional <Exception> .Empty));
        }
        public void FailWithActualExceptionReturnsExpectedResult()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            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.Buts, Is.EqualTo(Optional<Tuple<string, object>[]>.Empty));
            Assert.That(result.But, Is.EqualTo(new Optional<Exception>(actual)));
        }
        public void FailWithActualExceptionReturnsExpectedResult()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            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.Buts, Is.EqualTo(Optional <Tuple <string, object>[]> .Empty));
            Assert.That(result.But, Is.EqualTo(new Optional <Exception>(actual)));
        }
        public void FailWithActualEventsReturnsExpectedResult()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            var actual = new[] {new Fact(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.ButEvents, Is.EqualTo(new Optional<Fact[]>(actual)));
            Assert.That(result.ButException, Is.EqualTo(Optional<Exception>.Empty));
        }
        public void DoesNotEqualObjectOfOtherType()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.That(sut.Equals(new object()), Is.False);
        }
        public void DoesNotEqualNull()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.That(sut.Equals(null), Is.False);
        }
        public void FailWithNullExceptionThrows()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.Throws <ArgumentNullException>(() => { var _ = sut.Fail((Exception)null); });
        }
 void WriteWhen(EventCentricTestSpecification specification)
 {
     _writer.WriteLine("When");
     WriteMessage(specification.When);
 }
 /// <summary>
 /// Writes the specified test specification.
 /// </summary>
 /// <param name="specification">The test specification to write.</param>
 public void Write(EventCentricTestSpecification specification)
 {
     WriteGivens(specification);
     WriteWhen(specification);
     WriteThens(specification);
 }
        public void DoesEqualItself()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.That(sut.Equals(sut), Is.True);
        }
        public void UsingDefaultConstructorReturnsInstanceWithExpectedProperties(Tuple<string, object>[] givens,
                                                                                 object when,
                                                                                 Tuple<string, object>[] thens)
        {
            var sut = new EventCentricTestSpecification(givens, when, thens);

            Assert.That(sut.Givens, Is.EquivalentTo(givens));
            Assert.That(sut.When, Is.SameAs(when));
            Assert.That(sut.Thens, Is.EquivalentTo(thens));
        }
 void WriteThens(EventCentricTestSpecification specification)
 {
     _writer.WriteLine("Then");
     WriteEvents(specification.Thens);
 }
 void WriteWhen(EventCentricTestSpecification specification)
 {
     _writer.WriteLine("When");
     WriteMessage(specification.When);
 }
 /// <summary>
 /// Writes the specified test specification.
 /// </summary>
 /// <param name="specification">The test specification to write.</param>
 public void Write(EventCentricTestSpecification specification)
 {
     WriteGivens(specification);
     WriteWhen(specification);
     WriteThens(specification);
 }
        public void FailWithNullExceptionThrows()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.Throws<ArgumentNullException>(() => { var _ = sut.Fail((Exception) null); });
        }
 void WriteThens(EventCentricTestSpecification specification)
 {
     _writer.WriteLine("Then");
     WriteEvents(specification.Thens);
 }
        public void DoesEqualItself()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.That(sut.Equals(sut), Is.True);
        }
 /// <summary>
 /// Determines whether the specified <see cref="EventCentricTestSpecification" /> is equal to this instance.
 /// </summary>
 /// <param name="other">The <see cref="EventCentricTestSpecification" /> to compare with this instance.</param>
 /// <returns>
 ///   <c>true</c> if the specified <see cref="EventCentricTestSpecification" /> is equal to this instance; otherwise, <c>false</c>.
 /// </returns>
 protected bool Equals(EventCentricTestSpecification other)
 {
     return
         Equals(_givens, other._givens) &&
         Equals(_when, other._when) &&
         Equals(_thens, other._thens);
 }
        public void DoesNotEqualNull()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.That(sut.Equals(null), Is.False);
        }
        public void DoesNotEqualObjectOfOtherType()
        {
            var sut = new EventCentricTestSpecification(NoEvents, Message, NoEvents);

            Assert.That(sut.Equals(new object()), Is.False);
        }