示例#1
0
文件: Spec.cs 项目: FinestV/SpecLight
        ExceptionDispatchInfo CleanupAndGetThrower()
        {
            if (_finalActions != null)
            {
                _finalActions();
            }
            SpecReporter.Add(this);
            ConsoleOutcomePrinter.PrintOutcomes(this);

            //rethrow the first error if any
            return(Outcomes.Select(x => x.ExceptionDispatchInfo).FirstOrDefault(x => x != null));
        }
        private void ComparePrint(MarketDescriptionDTO dto, CultureInfo culture)
        {
            var names    = _names.Aggregate(string.Empty, (current, name) => current + $", {name.Key.TwoLetterISOLanguageName}-{name.Value}").Substring(2);
            var desc     = _descriptions.Aggregate(string.Empty, (current, d) => current + $", {d.Key.TwoLetterISOLanguageName}-{d.Value}");
            var specs    = Specifiers == null ? null : string.Join(", ", Specifiers.Select(s => s.Name));
            var outcomes = Outcomes == null ? null : string.Join(",", Outcomes.Select(s => s.Id));
            var maps     = Mappings == null ? null : string.Join(",", Mappings.Select(s => s.MarketTypeId));

            ExecutionLog.Debug($"Original Id={Id}, Names=[{names}], Descriptions=[{desc}], Variant=[{Variant}], Specifiers=[{specs}], Outocomes=[{outcomes}], Mappings=[{maps}].");

            var specsNew    = dto.Specifiers == null ? null : string.Join(", ", dto.Specifiers.Select(s => s.Name));
            var outcomesNew = dto.Outcomes == null ? null : string.Join(",", dto.Outcomes.Select(s => s.Id));
            var mapsNew     = dto.Mappings == null ? null : string.Join(",", dto.Mappings.Select(s => s.MarketTypeId));

            ExecutionLog.Debug($"New Id={dto.Id}, Name=[{culture.TwoLetterISOLanguageName}-{dto.Name}], Descriptions=[{dto.Description}], Variant=[{dto.Variant}], Specifiers=[{specsNew}], Outocomes=[{outcomesNew}], Mappings=[{mapsNew}].");
        }
示例#3
0
        void CleanupAndThrowIfFailed()
        {
            finalActions?.Invoke();
            SpecReporter.Add(this);
            ConsoleOutcomePrinter.PrintOutcomes(this, WriteLine);

            //rethrow the first error if any
            var thrower = Outcomes.Select(x => x.ExceptionDispatchInfo).FirstOrDefault(x => x != null);

            thrower?.Throw();

            //check if there were any un-inspected exception references
            var unInspectedExceptionReference = caughtExceptionReferences
                                                .Where(x => !x.Key.IsValueCreated)
                                                .Select(x => x.Value)
                                                .FirstOrDefault();

            if (unInspectedExceptionReference != null)
            {
                throw new Exception($"Error was thrown by step \'{unInspectedExceptionReference.Description}\', but was not inspected");
            }
        }