예제 #1
0
        private async Task <EventCentricTestResult> RunAsync(EventCentricTestSpecification spec)
        {
            var position = await _factWriter.PersistFacts(spec.Givens);

            var handleCommand = _handlerResolver.ResolveHandlerFor(spec.When);
            var result        = await Catch.Exception(async() => await handleCommand(spec.When));

            if (result.HasValue)
            {
                return(spec.Fail(result.Value));
            }

            var actualEvents = await _factReader.RetrieveFacts(position);

            return(actualEvents.SequenceEqual(spec.Thens, new WrappedFactComparerEqualityComparer(_comparer))
                ? spec.Pass(actualEvents)
                : spec.Fail(actualEvents));
        }
예제 #2
0
        private async Task <ExceptionCentricTestResult> RunAsync(ExceptionCentricTestSpecification spec)
        {
            var position = await _factWriter.PersistFacts(spec.Givens);

            var handleCommand = _handlerResolver.ResolveHandlerFor(spec.When);
            var result        = await Catch.Exception(async() => await handleCommand(spec.When));

            var actualEvents = await _factReader.RetrieveFacts(position);

            if (!result.HasValue)
            {
                return(actualEvents.Any() ? spec.Fail(actualEvents) : spec.Fail());
            }

            var actualException = result.Value;

            return(_comparer.Compare(spec.Throws, actualException).Any()
                ? spec.Fail(actualException)
                : spec.Pass(actualException));
        }