/// <summary> /// Runs the specified test specification. /// </summary> /// <param name="specification">The test specification to run.</param> /// <returns> /// The result of running the test specification. /// </returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="specification"/> is <c>null</c>.</exception> public EventCentricAggregateConstructorTestResult Run(EventCentricAggregateConstructorTestSpecification specification) { if (specification == null) throw new ArgumentNullException("specification"); IAggregateRootEntity sut = null; var result = Catch.Exception(() => sut = specification.SutFactory()); if (result.HasValue) { return specification.Fail(result.Value); } var actualEvents = sut.GetChanges().ToArray(); if (!actualEvents.SequenceEqual(specification.Thens, new WrappedEventComparerEqualityComparer(_comparer))) { return specification.Fail(actualEvents); } return specification.Pass(); }
/// <summary> /// Runs the specified test specification. /// </summary> /// <param name="specification">The test specification to run.</param> /// <returns> /// The result of running the test specification. /// </returns> /// <exception cref="ArgumentNullException">Thrown when <paramref name="specification"/> is <c>null</c>.</exception> public EventCentricAggregateConstructorTestResult Run(EventCentricAggregateConstructorTestSpecification specification) { if (specification == null) { throw new ArgumentNullException(nameof(specification)); } IAggregateRootEntity sut = null; var result = Catch.Exception(() => sut = specification.SutFactory()); if (result.HasValue) { return(specification.Fail(result.Value)); } #if NET20 var actualEvents = new List <object>(sut.GetChanges()).ToArray(); #else var actualEvents = sut.GetChanges().ToArray(); #endif if (!actualEvents.SequenceEqual(specification.Thens, new WrappedEventComparerEqualityComparer(_comparer))) { return(specification.Fail(actualEvents)); } return(specification.Pass()); }
public void FailEventsCanNotBeNull() { Assert.Throws <ArgumentNullException>(() => _sut.Fail((object[])null)); }