Пример #1
0
        public StepResult NextStep()
        {
            if (initBefore && lastStepResult == StepResult.NextRound)
            {
                InitRound();
            }
            if (round >= rounds)
            {
                return StepResult.Finished;
            }

            PerformInstruction();

            lastStepResult = StepResult.Continue;
            if (LiveWarriorsCount == 1 && WarriorsCount > 1)
            {
                liveWarriors.Peek().Result = RoundResult.Win;
                lastStepResult = StepResult.NextRound;
                NextRound();
            }
            else if (LiveWarriorsCount == 0 || cyclesLeft == 0)
            {
                lastStepResult = StepResult.NextRound;
                NextRound();
            }
            return lastStepResult;
        }
Пример #2
0
 public void HasFailedSteps_should_return_false_if_no_failed_steps()
 {
     var passed = new StepResult("Foo".AsStringStep(""), new Passed());
     _results.AddActionStepResult(passed);
     var pending = new StepResult("Bar".AsStringStep(""), new Pending("yadda"));
     _results.AddActionStepResult(pending);
     Assert.IsFalse(_results.HasFailedSteps());
 }
Пример #3
0
 public void HasFailedSteps_should_report_failed_if_at_least_one_step_failed()
 {
     var passed = new StepResult("Foo".AsStringStep(""), new Passed());
     _results.AddActionStepResult(passed);
     var failed = new StepResult("Foo".AsStringStep(""), new Failed(new Exception()));
     _results.AddActionStepResult(failed);
     Assert.IsTrue(_results.HasFailedSteps());
 }
Пример #4
0
 protected override void EstablishContext()
 {
     var memStream = new MemoryStream();
     var xmlWriter = new XmlTextWriter(memStream, Encoding.UTF8);
     _xmlOutputWriter = new XmlOutputWriter(xmlWriter, new List<EventReceived>());
     var result = new StepResult(Step("Given Foo"), Passed);
     _xmlOutputWriter.DoStringStep(result);
     xmlWriter.Flush();
     _xmlDoc = new XmlDocument();
     memStream.Seek(0, SeekOrigin.Begin);
     _xmlDoc.Load(memStream);
 }
Пример #5
0
        public void BeginMatch(IProject project)
        {
            if (project.EngineOptions.EngineMode != EngineMode.Match)
                throw new InvalidOperationException("This engine mode is supported only by method run");

            InitializeMatch(project);
            InitializeRound();

            results = new MatchResult(project);
            lastStepResult = StepResult.Start;
            initBefore = Project.EngineOptions.InitRoundBefore;
            rounds = rules.Rounds;
        }
Пример #6
0
        public void Run <TGrid>(TGrid grid, Dictionary <Coordinate, bool> buffer,
                                int?iterations = null)
            where TGrid : IConwayGrid
        {
            var result             = new StepResult();
            var executedIterations = 0;

            while (grid.HasLiveCells())
            {
                Step(result, grid, buffer);
                grid.SetDictionary(result.State);

                result.Clear();

                executedIterations++;
                if (iterations != null && executedIterations >= iterations)
                {
                    break;
                }
            }
        }
Пример #7
0
        protected override StepResult HandleResult(string result, Queue <ConfigInitWizardStep> steps, Config config, string workingDirectory)
        {
            switch (result)
            {
            case "0":
                steps.Enqueue(new EditConfigStep(Console, FileSystem));
                return(StepResult.Ok());

            case "1":
                config.AssemblyInformationalVersioningScheme = AssemblyInformationalVersioningScheme.FullInformationalVersion;
                steps.Enqueue(new EditConfigStep(Console, FileSystem));
                return(StepResult.Ok());

            case "2":
                config.AssemblyInformationalVersioningScheme = AssemblyInformationalVersioningScheme.NugetVersion;
                steps.Enqueue(new EditConfigStep(Console, FileSystem));
                return(StepResult.Ok());
            }

            return(StepResult.InvalidResponseSelected());
        }
            public async Task Dont_Use_Scoring_System_ReceivingPMode_When_Already_Configure()
            {
                // Arrange
                var expected = new ReceivePMode {
                    Id = "static-receive-configured"
                };

                // Act
                StepResult result = await _step.ExecuteAsync(
                    new MessagingContext(
                        AS4Message.Empty,
                        MessagingContextMode.Receive)
                {
                    ReceivingPMode = expected
                });

                // Assert
                Assert.Same(
                    expected,
                    result.MessagingContext.ReceivingPMode);
            }
Пример #9
0
        /// <summary>
        /// Find action that does not throw error on No Such Element or Element Not Visible
        /// </summary>
        /// <param name="step"></param>
        /// <returns>Pass = true if found, Pass = false if not found</returns>
        public StepResult FindSafeAction(TestStep step)
        {
            StepResult r = new StepResult();

            try {
                Actions actions = new Actions(_driver);
                actions.MoveToElement(GetBy(step.IdBy, step.IdValue));
                actions.Build().Perform();
                r = Pass(step);
            }
            catch (NoSuchElementException) {
                r = Fail(step);
            }
            catch (ElementNotVisibleException) {
                r = Fail(step);
            }
            catch (Exception ex) {
                r = Fail(step, ex);
            }
            return(r);
        }
Пример #10
0
        static void Main(string[] args)
        {
            Console.SetWindowSize(60, 25);
            Console.SetBufferSize(60, 1000);

            while (true)
            {
                using (var repository = new Repository())
                {
                    MainLogic  logic  = new MainLogic(repository);
                    StepResult result = logic.RunStep();
                    //вызываем у бизнес логики функцию
                    //так мы раньше вызывали меню
                    //и значение и присваиваем в переменную
                    if (result == StepResult.Exit)//это переписанный Userchoicecancel
                    {
                        break;
                    }
                }
            }
        }
Пример #11
0
        /// <summary>
        /// When the node is NOT in IBD, process and push the blocks in <see cref="BlockStoreLoop.PendingStorage"/> immediately
        /// to the block repository without checking batch size.
        /// </summary>
        private async Task <StepResult> ProcessWhenNotInIBDAsync(ProcessPendingStorageContext context)
        {
            this.logger.LogTrace("({0}:'{1}')", nameof(context.NextChainedBlock), context.NextChainedBlock);

            while (context.CancellationToken.IsCancellationRequested == false)
            {
                StepResult result = this.PrepareNextBlockFromPendingStorage(context);
                if (result == StepResult.Stop)
                {
                    break;
                }
            }

            if (context.PendingBlockPairsToStore.Any())
            {
                await this.PushBlocksToRepositoryAsync(context);
            }

            this.logger.LogTrace("(-):{0}", StepResult.Continue);
            return(StepResult.Continue);
        }
Пример #12
0
        protected override StepResult HandleResult(string result, Queue <ConfigInitWizardStep> steps, Config config, string workingDirectory)
        {
            switch (result)
            {
            case "0":
                steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem));
                return(StepResult.Ok());

            case "1":
                branchConfig.VersioningMode = VersioningMode.ContinuousDelivery;
                steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem));
                return(StepResult.Ok());

            case "2":
                branchConfig.VersioningMode = VersioningMode.ContinuousDeployment;
                steps.Enqueue(new ConfigureBranch(name, branchConfig, Console, FileSystem));
                return(StepResult.Ok());
            }

            return(StepResult.InvalidResponseSelected());
        }
        public void modify_increments_with_cell_results()
        {
            var result = new StepResult("foo", ResultStatus.ok)
            {
                cells = new[]
                {
                    CellResult.Error("a", "bad!"),
                    CellResult.Error("b", "worse!"),
                    CellResult.Success("c"),
                    CellResult.Failure("d", "different"),
                    CellResult.Failure("e", "different"),
                    CellResult.Failure("f", "different"),
                }
            };

            var counts = new Counts();

            result.Tabulate(counts);

            counts.ShouldEqual(1, 3, 2, 0);
        }
Пример #14
0
        /// <summary>
        /// Initializes step with the name passed.
        /// </summary>
        /// <param name="stepName">Name of the step.</param>
        public void BeginStep(string stepName)
        {
            lock (_locker)
            {
                if (_pause)
                {
                    System.Diagnostics.Debug.WriteLine("Begin step - pause");
                    DoPause();
                }

                _currentStepNum++;
                _currentStep = new StepResult {
                    Number = _currentStepNum, StepName = stepName, Status = StepStatus.Passed, Message = stepName
                };

                if (OnStepStarted != null)
                {
                    OnStepStarted(_currentStep);
                }
            }
        }
Пример #15
0
        /// <summary>
        /// When the node disposes, process all the blocks in <see cref="BlockStoreLoop.PendingStorage"/> until
        /// its empty
        /// </summary>
        private async Task <StepResult> ProcessWhenDisposingAsync(ProcessPendingStorageContext context)
        {
            this.logger.LogTrace("({0}:'{1}')", nameof(context.NextChainedBlock), context.NextChainedBlock);

            while (this.BlockStoreLoop.PendingStorage.Count > 0)
            {
                StepResult result = this.PrepareNextBlockFromPendingStorage(context);
                if (result == StepResult.Stop)
                {
                    break;
                }
            }

            if (context.PendingBlockPairsToStore.Any())
            {
                await this.PushBlocksToRepositoryAsync(context);
            }

            this.logger.LogTrace("(-):{0}", StepResult.Stop);
            return(StepResult.Stop);
        }
Пример #16
0
        internal static async Task <MessagingContext> ExecuteStepsAsync(MessagingContext context, StepConfiguration stepConfig)
        {
            try
            {
                IEnumerable <IStep> steps  = CreateSteps(stepConfig.NormalPipeline);
                StepResult          result = await ExecuteSteps(steps, context);

                bool weHaveAnyUnhappyPath = stepConfig.ErrorPipeline != null;
                if (result.Succeeded == false && weHaveAnyUnhappyPath && result.MessagingContext.Exception == null)
                {
                    IEnumerable <IStep> unhappySteps = CreateSteps(stepConfig.ErrorPipeline);
                    result = await ExecuteSteps(unhappySteps, result.MessagingContext);
                }

                return(result.MessagingContext);
            }
            catch (Exception ex)
            {
                return(new MessagingContext(ex));
            }
        }
        protected override StepResult HandleResult(string result, Queue <ConfigInitWizardStep> steps, Config config, string workingDirectory, IFileSystem fileSystem)
        {
            switch (result.ToLower())
            {
            case "y":
                Console.WriteLine("GitFlow is likely a good fit, the 'develop' branch can be used " +
                                  "for active development while stabilising the next release.");
                Console.WriteLine();
                Console.WriteLine("GitHubFlow is designed for a lightweight workflow where master is always " +
                                  "good to deploy to production and feature branches are used to stabilise " +
                                  "features, once stable they are merged to master and made available in the next release");
                steps.Enqueue(new PickBranchingStrategyStep());
                return(StepResult.Ok());

            case "n":
                steps.Enqueue(new PickBranchingStrategy3Step());
                return(StepResult.Ok());
            }

            return(StepResult.InvalidResponseSelected());
        }
Пример #18
0
        public async Task <StepResult> Execute(ClientRequest request)
        {
            var stepResult = new StepResult();

            stepResult.Step = RegistrationStep.Step1;

            if (string.IsNullOrEmpty(request.Email))
            {
                stepResult.Errors.Add(new ValidationError(nameof(request.Email), "Null or empty"));
            }

            if (string.IsNullOrEmpty(request.Passowrd))
            {
                stepResult.Errors.Add(new ValidationError(nameof(request.Passowrd), "Null or empty"));
            }

            //Одна секунда
            await Task.Delay(1000);

            return(stepResult);
        }
Пример #19
0
        private static SpecResults buildResultsForContextCreationFailure(SpecExecutionRequest request, Exception ex,
                                                                         Timings timings)
        {
            var result = new StepResult(request.Specification.id, ex)
            {
                position = Stage.context
            };
            var perf = timings.Finish();

            return(new SpecResults
            {
                Attempts = request.Plan.Attempts,
                Duration = timings.Duration,
                Performance = perf.ToArray(),
                Counts = new Counts(0, 0, 1, 0),
                Results = new IResultMessage[]
                {
                    result
                }
            });
        }
Пример #20
0
        public override async Task <StepResult> Do()
        {
            StepResult result = new StepResult();

            result.ResultText = string.Empty;

            try
            {
                result.ResultText = file.CopyTo(Path.Combine(Parameters["DestinationPath"].Value, file.Name), overwrite).FullName;

                LogMessage(LogLevel.Info, string.Concat("Copied file to ", result.ResultText));
            }
            catch
            {
                LogMessage(LogLevel.Error, string.Concat("File couldn't be copied to", result.ResultText));
                return(result);
            }

            result.Done = File.Exists(result.ResultText);
            return(result);
        }
Пример #21
0
        /// <summary>
        /// Handles "StepCompleted" event.
        /// </summary>
        /// <param name="result"></param>
        void _td_StepCompleted(StepResult result)
        {
            System.ServiceModel.FaultException fault = result.Exception as System.ServiceModel.FaultException;
            bool bFault = false;

            if (fault != null)
            {
                bFault = true;
            }

            string stepResult = string.Format("STEP {0}", result.Status.ToString().ToUpper());

            if (result.Status == StepStatus.Failed && !bFault)
            {
                WriteLog(result.Message, LogEntryLevel.StepDetails);
            }
            WriteLog(stepResult, LogEntryLevel.Step);
            WriteLog(string.Empty, LogEntryLevel.Test);

            DisplayStepResult(result);
        }
Пример #22
0
        /// <summary>
        /// Start sending the AS4 Messages
        /// to the consuming business application
        /// </summary>
        /// <param name="messagingContext"></param>
        /// <returns></returns>
        public async Task <StepResult> ExecuteAsync(MessagingContext messagingContext)
        {
            if (messagingContext == null)
            {
                throw new ArgumentNullException(nameof(messagingContext));
            }

            if (messagingContext.ReceivingPMode == null)
            {
                throw new InvalidOperationException(
                          "Unable to send DeliverMessage: no ReceivingPMode is set");
            }

            if (messagingContext.ReceivingPMode.MessageHandling?.DeliverInformation == null)
            {
                throw new InvalidOperationException(
                          $"Unable to send the DeliverMessage: the ReceivingPMode {messagingContext.ReceivingPMode.Id} does not contain any <DeliverInformation />." +
                          "Please provide a correct <DeliverInformation /> tag to indicate where the deliver message (and its attachments) should be send to.");
            }

            if (messagingContext.ReceivingPMode.MessageHandling.DeliverInformation.DeliverMethod?.Type == null)
            {
                throw new InvalidOperationException(
                          $"Unable to send the DeliverMessage: the ReceivingPMode {messagingContext.ReceivingPMode.Id} "
                          + "does not contain any <Type/> element indicating the uploading strategy in the MessageHandling.Deliver.DeliverMethod element. "
                          + "Default sending strategies are: 'FILE' and 'HTTP'. See 'Deliver Uploading' for more information");
            }

            Logger.Trace($"{messagingContext.LogTag} Start sending the DeliverMessage to the consuming business application...");
            SendResult result =
                await SendDeliverMessageAsync(
                    messagingContext.ReceivingPMode.MessageHandling.DeliverInformation.DeliverMethod,
                    messagingContext.DeliverMessage);

            Logger.Trace($"{messagingContext.LogTag} Done sending the DeliverMesssage to the consuming business application");

            await UpdateDeliverMessageAsync(messagingContext, result);

            return(StepResult.Success(messagingContext));
        }
Пример #23
0
        public void AddReportStep(string description, string actualResult, StepResult stepResult, string screenShotPath)
        {
            string        reportStepRow = string.Empty;
            string        replaceValue  = string.Empty;
            StringBuilder reportStepBuilder;

            switch (stepResult)
            {
            case StepResult.PASS:
                noOfStepsPassed++;
                overAllStepsPassed++;
                reportStepRow = HelperClass.rptPASSRow;
                break;

            case StepResult.FAIL:
                noOfStepsFailed++;
                overAllStepsFailed++;
                reportStepRow = HelperClass.rptFAILRow;
                break;

            case StepResult.WARNING:
                reportStepRow = HelperClass.rptWARNINGRow;
                overAllWarningSteps++;
                break;
            }
            stepNo++;
            reportStepBuilder = new StringBuilder(reportStepRow);
            replaceValue      = "##" + "StepNoValue" + "##";
            reportStepBuilder.Replace(replaceValue, Convert.ToString(stepNo));
            replaceValue = "##" + "StepNoDesc" + "##";
            reportStepBuilder.Replace(replaceValue, description);
            replaceValue = "##" + "StepActualResult" + "##";
            reportStepBuilder.Replace(replaceValue, actualResult);
            if (stepResult == StepResult.FAIL)
            {
                replaceValue = "##" + "ScreenShotPath" + "##";
                reportStepBuilder.Replace(replaceValue, screenShotPath);
            }
            reportBuider.Append(reportStepBuilder);
        }
        public async Task SelectsUserMessage_IfUserMessageMatchesCriteria()
        {
            // Arrange
            const string expectedMpc = "message-mpc";

            InsertUserMessage(expectedMpc, MessageExchangePattern.Push, Operation.ToBeSent);
            InsertUserMessage("yet-another-mpc", MessageExchangePattern.Pull, Operation.DeadLettered);
            InsertUserMessage(expectedMpc, MessageExchangePattern.Pull, Operation.ToBeSent);

            // Act
            StepResult result = await ExerciseSelection(expectedMpc);

            // Assert

            AS4Message as4Message = await RetrieveAS4MessageFromContext(result.MessagingContext);

            UserMessage userMessage = as4Message.FirstUserMessage;

            Assert.Equal(expectedMpc, userMessage.Mpc);
            AssertOutMessage(userMessage.MessageId, m => Assert.True(m.Operation == Operation.Sent));
            Assert.NotNull(result.MessagingContext.SendingPMode);
        }
        public async Task Sign_Receipt_If_ReceivingPMode_ResponseSigning_Is_Enabled()
        {
            // Arrange
            var ctx = new MessagingContext(
                AS4Message.Create(new Receipt($"receipt-{Guid.NewGuid()}", $"user-{Guid.NewGuid()}")),
                MessagingContextMode.Send)
            {
                ReceivingPMode = new ReceivingProcessingMode
                {
                    ReplyHandling =
                    {
                        ResponseSigning = CreateEnabledSigningInformation()
                    }
                }
            };

            // Act
            StepResult result = await ExerciseSigning(ctx);

            // Assert
            Assert.True(result.MessagingContext.AS4Message.IsSigned);
        }
Пример #26
0
        protected override StepResult ExecuteInternal(TContext ctx)
        {
            StagingCache cache = ctx.BeginStaging();

            StepResult result = child.Execute(ctx);

            if (result != StepResult.Positive)
            {
                ctx.EndStaging(cache, false);
                return(result);
            }

            while (child.Execute(ctx) == StepResult.Positive)
            {
                ;
            }

            ctx.EndStaging(cache, true, false);
            ctx.AddSymbol(new Production(Name, cache.Symbols));

            return(StepResult.Positive);
        }
Пример #27
0
        public void OneStep_HasBothSuccessAndFailStepResult_DoesntThrowException()
        {
            var stepper = new Stepper();

            stepper.AddFirstStep(() =>
            {
                if (true)
                {
                    return(StepResult.Success(1));
                }
                return(StepResult.Failure());
            })
            .Then(test =>
            {
                Console.WriteLine(test);
                return(StepResult.Success());
            });

            var jobResult = stepper.RunJob();

            Assert.AreEqual(false, jobResult.HasFailed);
        }
Пример #28
0
        protected override StepResult HandleResult(string result, Queue <ConfigInitWizardStep> steps, Config config, string workingDirectory)
        {
            switch (result)
            {
            case "1":
                steps.Enqueue(new GitFlowSetupStep(Console, FileSystem));
                break;

            case "2":
                steps.Enqueue(new GitHubFlowStep(Console, FileSystem));
                break;

            case "3":
                steps.Enqueue(new PickBranchingStrategy1Step(Console, FileSystem));
                break;

            default:
                return(StepResult.InvalidResponseSelected());
            }

            return(StepResult.Ok());
        }
Пример #29
0
        public void LogException(string id, Exception ex, PerfRecord record, object position = null)
        {
            if (id.IsEmpty())
            {
                id       = Specification.id;
                position = Stage.context;
            }

            Reporting.ReporterFor <ExceptionReport>().Log(ex);

            ex = unwrapException(ex);

            if (ex is StorytellerCriticalException)
            {
                HadCriticalException = true;

                // TODO -- hokey. Watch if this becomes a pattern
                if (ex.InnerException is MissingFixtureException)
                {
                    LogResult(new StepResult(id, ResultStatus.invalid)
                    {
                        error    = ex.InnerException.Message,
                        position = position
                    }, record);
                    return;
                }
            }

            CatastrophicException = ex as StorytellerCatastrophicException;

            var result = new StepResult(id, ResultStatus.error)
            {
                position = position
            };

            result.error = ExceptionFormatting.ToDisplayMessage(ex, out result.errorDisplay);

            LogResult(result, record);
        }
Пример #30
0
        protected override StepResult HandleResult(string result, Queue <ConfigInitWizardStep> steps, Config config, string workingDirectory, IFileSystem fileSystem)
        {
            switch (result)
            {
            case "1":
                config.VersioningMode = VersioningMode.ContinuousDelivery;
                steps.Enqueue(returnToStep);
                return(StepResult.Ok());

            case "2":
                config.VersioningMode = VersioningMode.ContinuousDeployment;
                steps.Enqueue(returnToStep);
                return(StepResult.Ok());

            case "0":
            case "3":
                steps.Enqueue(returnToStep);
                return(StepResult.Ok());
            }

            return(StepResult.InvalidResponseSelected());
        }
Пример #31
0
    protected override StepResult HandleResult(string?result, Queue <ConfigInitWizardStep> steps, Config config, string workingDirectory)
    {
        var editConfigStep = this.StepFactory.CreateStep <EditConfigStep>() !;

        switch (result)
        {
        case "0":
            steps.Enqueue(editConfigStep);
            return(StepResult.Ok());

        case "1":
            GenerateBasicConfig(workingDirectory);
            steps.Enqueue(editConfigStep);
            return(StepResult.Ok());

        case "2":
            GenerateNuGetConfig(workingDirectory);
            steps.Enqueue(editConfigStep);
            return(StepResult.Ok());
        }
        return(StepResult.InvalidResponseSelected());
    }
        public void ResultObject_WithStoreTest()
        {
            var expectedValue = "Expected Value";
            var storageKey    = "validStoreKey";

            var result     = new StepResult <string>(expectedValue, true);
            var resultSerd = Utils.SerializeToJSON(result);

            var storeManager = Substitute.For <IStorageManager>();

            storeManager.GetData(Arg.Any <S3StorageReference>()).Returns(info => resultSerd);

            var context = Substitute.For <WorkflowDecisionContext>(storeManager);

            context.ResultRef = storageKey;

            AssertObjectEquals.PropertyValuesAreEqual(context.ResultObject, result);
            Assert.Equal(expectedValue, context.ResultData);

            // Checking if the GetSerializedObjectFromStore method was called with exact parameter.
            storeManager.Received().GetData(Arg.Is <S3StorageReference>(x => x.StorageKey == storageKey));
        }
        public async Task Creates_Error_Based_On_ErrorResult_Information()
        {
            // Arrange
            AS4Message as4Message = CreateFilledAS4Message();
            var        fixture    = new MessagingContext(
                as4Message,
                MessagingContextMode.Unknown)
            {
                ErrorResult    = new ErrorResult("error", ErrorAlias.ConnectionFailure),
                ReceivingPMode = new ReceivingProcessingMode()
            };

            // Act
            StepResult result = await CreateErrorStep().ExecuteAsync(fixture);

            // Assert
            var error = result.MessagingContext.AS4Message.FirstSignalMessage as Error;

            Assert.NotNull(error);
            Assert.Equal("message-id", error.RefToMessageId);
            Assert.Equal(ErrorCode.Ebms0005, error.ErrorLines.First().ErrorCode);
        }
Пример #34
0
        /// <summary>
        /// Execute the step for a given <paramref name="messagingContext"/>.
        /// </summary>
        /// <param name="messagingContext">Message used during the step execution.</param>
        /// <returns></returns>
        public async Task <StepResult> ExecuteAsync(MessagingContext messagingContext)
        {
            if (messagingContext?.AS4Message == null)
            {
                throw new InvalidOperationException(
                          $"{nameof(UpdateReceivedAS4MessageBodyStep)} requires an AS4Message to update but no AS4Message is present in the MessagingContext");
            }

            Logger.Trace("Updating the received message body...");
            using (DatastoreContext datastoreContext = _createDatastoreContext())
            {
                var repository = new DatastoreRepository(datastoreContext);
                var service    = new InMessageService(_configuration, repository);

                service.UpdateAS4MessageForMessageHandling(
                    messagingContext.AS4Message,
                    messagingContext.SendingPMode,
                    messagingContext.ReceivingPMode,
                    _messageBodyStore);

                await datastoreContext.SaveChangesAsync().ConfigureAwait(false);
            }

            if (messagingContext.ReceivedMessageMustBeForwarded)
            {
                // When the Message has to be forwarded, the remaining Steps must not be executed.
                // The MSH must answer with a HTTP Accepted status-code, so an empty context must be returned.
                messagingContext.ModifyContext(AS4Message.Empty);

                Logger.Info(
                    "Stops execution to return empty SOAP envelope to the orignal sender. " +
                    "This happens when the message must be forwarded");

                return(StepResult.Success(messagingContext).AndStopExecution());
            }

            return(StepResult.Success(messagingContext));
        }
Пример #35
0
        /// <summary>
        /// 获取子节点执行结果的状态
        /// </summary>
        private static void GetStepsResultFlag(StepTaskEntityBase stepEntry, ref bool isTimeout, ref bool isError,
                                               ref bool isAbort, ref bool isFailed)
        {
            if (null == stepEntry)
            {
                return;
            }
            StepTaskEntityBase subStep = stepEntry;

            while (null != subStep)
            {
                StepResult result = subStep.Result;
                switch (result)
                {
                case StepResult.Failed:
                    isFailed = true;
                    break;

                case StepResult.Abort:
                    isAbort = true;
                    break;

                case StepResult.Timeout:
                    isTimeout = true;
                    break;

                case StepResult.Error:
                    isError = true;
                    break;

                default:
                    // ignore
                    break;
                }
                GetStepsResultFlag(subStep.SubStepRoot, ref isTimeout, ref isError, ref isAbort, ref isFailed);
                subStep = subStep.NextStep;
            }
        }
Пример #36
0
        protected virtual void EstablishContext()
        {
            var memStream = new MemoryStream();
            var xmlWriter = new XmlTextWriter(memStream, Encoding.UTF8);

            var story = new Feature("StoryTitle");
            var scenarioResult = new ScenarioResult(story, "ScenarioTitle");
            var actionStepResult = new StepResult(Step("Given Foo"), Passed);
            scenarioResult.AddActionStepResult(actionStepResult);

            var eventsReceived = new List<EventReceived>
                                     {
                                         new EventReceived("", EventType.RunStart),
                                         new EventReceived("StoryTitle", EventType.FeatureStart),
                                         new EventReceived("As a x\nI want y\nSo That z", EventType.FeatureNarrative),
                                         new EventReceived("ScenarioTitle", EventType.ScenarioStart),
                                         new ScenarioResultEventReceived(scenarioResult),
                                         new EventReceived("", EventType.FeatureFinished),
                                         new EventReceived("", EventType.RunFinished)
                                     };

            _xmlOutputWriter = new XmlOutputWriter(xmlWriter, eventsReceived);
        }
Пример #37
0
        public StepResult NextStep()
        {
            if (lastInstructionWatchMode)
            {
                //copy instruction
                lastInstruction = NextInstruction;
            }

            lastStepResult = (StepResult)pMarsDll.pMarsStepMatch();
            dllCoreLoaded = false;
            dllTasksLoaded = false;
            dllWarriorsLoaded = false;
            cycle++;

            if (lastStepResult > StepResult.Continue)
            {
                if (lastStepResult != StepResult.Finished)
                {
                    cycle = 0;
                }
                else
                {
                    pMarsDll.pMarsResultsMatch();
                    dllWarriorsLoaded = false;
                    CopyWarriors();
                    results.score = new int[rules.WarriorsCount];
                    for (int w = 0; w < rules.WarriorsCount; w++)
                    {
                        results.score[w] = warriorsDllCopy[w].totalScore;
                    }
                }
            }
            return lastStepResult;
        }
Пример #38
0
 protected void InitRound()
 {
     round++;
     if (round >= rounds)
     {
         lastStepResult = StepResult.Finished;
     }
     else
     {
         InitializeRound();
     }
 }
Пример #39
0
 public void StepFinished(StepResult stepResult)
 {
     contextHandler.OnStepFinishedEvent();
     if (OnStepFinished != null)
         OnStepFinished(this, new EventArgs<StepResult>(stepResult));
 }
Пример #40
0
            protected override void EstablishContext()
            {
                var memStream = new MemoryStream();
                var xmlWriter = new XmlTextWriter(memStream, Encoding.UTF8);

                var feature = new Feature("FeatureTitle");
                var scenarioResult = new ScenarioResult(feature, "ScenarioTitle");
                var actionStepResult1 = new StepResult(Step("Given a"), Passed);
                scenarioResult.AddActionStepResult(actionStepResult1);
                var actionStepResult2 = new StepResult(Step("When b"), Passed);
                scenarioResult.AddActionStepResult(actionStepResult2);
                var actionStepResult3 = new StepResult(Step("Then c"), Passed);
                scenarioResult.AddActionStepResult(actionStepResult3);

                var eventsReceived = new List<EventReceived>
                                         {
                                             new EventReceived("ScenarioTitle", EventType.ScenarioStart),
                                             new ScenarioResultEventReceived(scenarioResult)
                                         };

                _xmlOutputWriter = new XmlOutputWriter(xmlWriter, eventsReceived);
                _xmlOutputWriter.DoScenario(eventsReceived[0], scenarioResult);
                xmlWriter.Flush();
                _xmlDoc = new XmlDocument();
                memStream.Seek(0, SeekOrigin.Begin);
                _xmlDoc.Load(memStream);
            }
Пример #41
0
 public EngineEvent(EngineInstruction executedInstruction, int cycles, int cyclesLeft, int ip, EngineWarrior warrior, StepResult prevStepResult)
 {
     ExecutedInstruction = executedInstruction;
     Cycles = cycles;
     CyclesLeft = cyclesLeft;
     Ip = ip;
     Warrior = warrior;
     PrevStepResult = prevStepResult;
     instructionsChanged = new Stack<EngineInstruction>();
 }
Пример #42
0
            IEnumerable<EventReceived> CreateSecondFeature()
            {
                var feature = new Feature("Second feature");
                var scenarioResult = new ScenarioResult(feature, "ScenarioTitle");
                var actionStepResult1 = new StepResult(Step("Given a"), Passed);
                scenarioResult.AddActionStepResult(actionStepResult1);
                var actionStepResult2 = new StepResult(Step("When b"), Passed);
                scenarioResult.AddActionStepResult(actionStepResult2);
                var actionStepResult3 = new StepResult(Step("Then c"), Passed);
                scenarioResult.AddActionStepResult(actionStepResult3);

                var eventsReceived = new List<EventReceived>
                                         {
                                             new EventReceived(feature.Title, EventType.FeatureStart),
                                             new EventReceived("As a x\nI want y\nSo That z", EventType.FeatureNarrative),
                                             new EventReceived("ScenarioTitle", EventType.ScenarioStart),
                                             new ScenarioResultEventReceived(scenarioResult),
                                             new EventReceived(feature.Title, EventType.FeatureFinished)
                                         };
                return eventsReceived;
            }
Пример #43
0
 private void CheapCheck(StepResult resOne, StepResult resTwo, Check origCheck, bool precise)
 {
     if (resOne != resTwo)
     {
         throw new EngineDifferException("StepRes",
                                         new Check(0, origCheck.FromCycle, origCheck.ToCycle, origCheck.Step / 2));
     }
     if (engineOne.Cycle != engineTwo.Cycle)
     {
         throw new EngineDifferException("Cycle", new Check(engineOne.Round, engineOne.Cycle, precise));
     }
     if (engineOne.Round != engineTwo.Round)
     {
         throw new EngineDifferException("Round", new Check(engineOne.Round, engineOne.Cycle, precise));
     }
     if (engineOne.LiveWarriorsCount != engineTwo.LiveWarriorsCount)
     {
         throw new EngineDifferException("Died", new Check(engineOne.Round, engineOne.Cycle, precise));
     }
     if (engineOne.CyclesLeft != engineTwo.CyclesLeft)
     {
         throw new EngineDifferException("CyclesLeft", new Check(engineOne.Round, engineOne.Cycle, precise));
     }
     if (engineOne.NextWarriorIndex != engineTwo.NextWarriorIndex)
     {
         throw new EngineDifferException("Cheating", new Check(engineOne.Round, engineOne.Cycle, precise));
     }
 }
Пример #44
0
 private string TypeAsString(StepResult stepResult)
 {
     if (stepResult.Result is Pending && (stepResult.Result is Skipped == false))
         return "PENDING";
     return stepResult.Result.ToString().ToUpper();
 }
Пример #45
0
        private void WriteTableSteps(StepResult stepResult)
        {
            if (stepResult.StringStep is StringTableStep == false)
                return;

            var stringTableStep = stepResult.StringStep as StringTableStep;
            var heeader = stringTableStep.TableSteps.First();
            writer.WriteColorString("   " + heeader.ColumnNamesToString(), GetColorForResult(stepResult.Result));
            foreach (var tableStep in stringTableStep.TableSteps)
                writer.WriteColorString("   " + tableStep.ColumnValuesToString(), GetColorForResult(stepResult.Result));
        }
Пример #46
0
 public void DoStringStep(StepResult result)
 {
     Writer.WriteStartElement("step");
     Writer.WriteAttributeString("name", result.StringStep.ToString().TrimEnd());
     Writer.WriteAttributeString("outcome", result.Result.ToString());
     if (result.Result.GetType() == typeof(Failed))
         Writer.WriteElementString("failure", result.Message);
     if (result.StringStep is StringTableStep)
         DoStringTableStep(result.StringStep as StringTableStep);
     Writer.WriteEndElement();
 }