Exemplo n.º 1
0
        public void UsingDefaultConstructorReturnsInstanceWithExpectedProperties(Fact[] 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));
        }
Exemplo n.º 2
0
        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.ButException, Is.EqualTo(Optional <Exception> .Empty));
        }
        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));
            }
        }
Exemplo n.º 4
0
        public void FailWithActualEventsReturnsExpectedResult()
        {
            var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception);

            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));
        }
Exemplo n.º 5
0
 private ExceptionCentricTestResult Run(ExceptionCentricTestSpecification specification)
 {
     return(new ExceptionCentricTestSpecificationRunner(CreateExceptionComparer(), _factRepository,
                                                        _factRepository, _handlerResolver.Object).Run(specification));
 }
Exemplo n.º 6
0
        public void DoesEqualItself()
        {
            var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception);

            Assert.That(sut.Equals((object)sut), Is.True);
        }
Exemplo n.º 7
0
        public void DoesNotEqualObjectOfOtherType()
        {
            var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception);

            Assert.That(sut.Equals(new object()), Is.False);
        }
Exemplo n.º 8
0
        public void DoesNotEqualNull()
        {
            var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception);

            Assert.That(sut.Equals(null), Is.False);
        }
Exemplo n.º 9
0
        public void FailWithNullEventsThrows()
        {
            var sut = new ExceptionCentricTestSpecification(NoEvents, Message, Exception);

            Assert.Throws <ArgumentNullException>(() => { var _ = sut.Fail((Fact[])null); });
        }