/// <summary>
 /// Adds results of command execution to context.
 /// </summary>
 /// <param name="command">Executed command.</param>
 /// <param name="integrationEvent">Expected event.</param>
 /// <param name="result">Execution result.</param>
 /// <returns>Updated execution context.</returns>
 public TestFlowExecutionContext Update(Command command, IntegrationEvent integrationEvent, IExecutionResult result)
 {
     return(new TestFlowExecutionContext(
                Host,
                AggregateVersions,
                ExecutedCommands.Add(command),
                ExpectedEvents.Add(integrationEvent),
                ExecutionResults.Add(result)));
 }
        public string GetExecutedCommands()
        {
            var sb = new StringBuilder();

            var commandList = ExecutedCommands
                              .Select(x => x.Recreate(OnCommandGetting(x.CommandText)))
                              .Select(x => x.ExtractToText());

            sb.AppendFormat("{0}", string.Join(Environment.NewLine + "----" + Environment.NewLine, commandList));

            return(sb.ToString());
        }
 protected TestFlowExecutionContextBase(
     SubdomainTestHost host,
     ImmutableDictionary <string, int> aggregateVersions,
     ImmutableList <Command> commands,
     ImmutableList <IntegrationEvent> expectedEvents,
     ImmutableList <IExecutionResult> results)
 {
     Host = host;
     AggregateVersions = AggregateVersions.AddRange(aggregateVersions);
     ExecutedCommands  = ExecutedCommands.AddRange(commands);
     ExpectedEvents    = ExpectedEvents.AddRange(expectedEvents);
     ExecutionResults  = ExecutionResults.AddRange(results);
 }
        public void Summary()
        {
            var commands = new List<IItemCommand>()
            {
                new DeleteItemCommand(new ItemChange(ItemChangeType.Delete, new Item("index2.html"))),
                new UploadItemCommand(new ItemChange(ItemChangeType.Add, new Item("index.html"))),
                new NullItemCommand()
            };
            var executedCommands = new ExecutedCommands(commands);

            var summary = executedCommands.ToString();

            var expectedSummary = "index.html\tUploaded" + Environment.NewLine +
                "index2.html\tDeleted" + Environment.NewLine;
            Assert.AreEqual(expectedSummary, summary);
        }
        public void SummaryInFrench()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-CA");
            var commands = new List <IItemCommand>()
            {
                new DeleteItemCommand(new ItemChange(ItemChangeType.Delete, new Item("index2.html"))),
                new UploadItemCommand(new ItemChange(ItemChangeType.Add, new Item("index.html"))),
                new NullItemCommand()
            };
            var executedCommands = new ExecutedCommands(commands);

            var summary = executedCommands.ToString();

            Assert.IsNotNull(summary);
            Assert.IsTrue(summary.StartsWith("index.html"));
            Assert.AreEqual(45, summary.Length);
        }
        public void Summary()
        {
            var commands = new List <IItemCommand>()
            {
                new DeleteItemCommand(new ItemChange(ItemChangeType.Delete, new Item("index2.html"))),
                new UploadItemCommand(new ItemChange(ItemChangeType.Add, new Item("index.html"))),
                new NullItemCommand()
            };
            var executedCommands = new ExecutedCommands(commands);

            var summary = executedCommands.ToString();

            var expectedSummary = "index.html\tUploaded" + Environment.NewLine +
                                  "index2.html\tDeleted" + Environment.NewLine;

            Assert.AreEqual(expectedSummary, summary);
        }
        public void SummaryInFrench()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-CA");
            var commands = new List<IItemCommand>()
            {
                new DeleteItemCommand(new ItemChange(ItemChangeType.Delete, new Item("index2.html"))),
                new UploadItemCommand(new ItemChange(ItemChangeType.Add, new Item("index.html"))),
                new NullItemCommand()
            };
            var executedCommands = new ExecutedCommands(commands);

            var summary = executedCommands.ToString();

            Assert.IsNotNull(summary);
            Assert.IsTrue(summary.StartsWith("index.html"));
            Assert.AreEqual(45, summary.Length);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Get all commands have been executed successfully or failed
        /// </summary>
        public string GetCommands()
        {
            var sb = new StringBuilder();

            var commandList = ExecutedCommands
                              .Select(x => x.Recreate(OnCommandGetting(x.CommandText)))
                              .Select(x => x.ExtractToText());

            sb.AppendFormat("ExecutedCommands: {0}", string.Join(Environment.NewLine + "----" + Environment.NewLine, commandList));
            sb.AppendLine("--------------");

            var failedLogs = FailedCommands.Select(x => string.Format("Command: {0}, Error: {1}", x.Key, x.Value));

            sb.AppendFormat("FailedCommands: {0}", string.Join(Environment.NewLine + "----" + Environment.NewLine, failedLogs));
            sb.AppendLine();

            return(sb.ToString());
        }
        public virtual void Update(float current_time)
        {
#if DEBUG
            ExecutedCommands.ForEach(c => c.IsExecuted = false);
            ExecutedCommands.Clear();
#endif
            foreach (var pair in CommandMap)
            {
                var timeline = pair.Value;
                var command  = timeline.PickCommand(current_time);

                if (command == null)
                {
                    continue;
                }

                command.Execute(this, current_time);
#if DEBUG
                MarkCommandExecuted(command);
#endif
            }

            IsVisible = (Color.W != 0);
        }
Exemplo n.º 10
0
 public void ExecuteCommand(RealtimeCommand cmd)
 {
     ExecutedCommands.Add(cmd);
 }
Exemplo n.º 11
0
 public void Execute(ICommand command)
 {
     ExecutedCommands.Add(command);
 }
Exemplo n.º 12
0
 private string GetMessageBodyForSuccess()
 {
     return(ExecutedCommands.ToString());
 }