public void RedoUndo()
        {
            var command = new FakeCommand();
            var executor = new CommandExecutor();
            executor.Redo();

            executor.Execute<FakeCommand>((configuration) =>
            {
                configuration.OnSuccess((s) => { });
                configuration.OnProgress((p) => { });
                configuration.OnFailure((f) => { });
                configuration.ConstructUsing(() => command);
            });

            Assert.True(executor.CanUndo);
            Assert.False(executor.CanRedo);

            executor.Undo();

            Assert.False(executor.CanUndo);
            Assert.True(executor.CanRedo);

            executor.Redo();

            Assert.True(executor.CanUndo);
            Assert.False(executor.CanRedo);
        }
        public void Execute_NoHandlerDefined_ThrowsException()
        {
            var commandDispatcher = new CommandExecutor(t => { throw new Exception(); }, _validationProcessor);
              var expectedMessage = string.Format("Can not resolve handler for ICommandHandler<{0}>", typeof(ICommand).Name);
              A.CallTo(() => _validationProcessor.Validate(_command)).Returns(new ValidationStatus());

              Assert.That(() => commandDispatcher.Execute(_command), Throws.InstanceOf<ResolverException>().And.Message.EqualTo(expectedMessage));
        }
        public void Execute_InvoiceModelIsInvalid_HandlerHandleMustNotHaveHappened()
        {
            var commandDispatcher = new CommandExecutor(t => _handler, _validationProcessor);
              A.CallTo(() => _validationProcessor.Validate(_command)).Returns(new ValidationStatus(new List<ValidationError> { new ValidationError("error") }));

              commandDispatcher.Execute(_command);

              A.CallTo(() => _handler.Handle(A<ICommand>._)).MustNotHaveHappened();
        }
        public void Execute_InvoiceModelIsValid_ValidationStateIsValid()
        {
            var commandDispatcher = new CommandExecutor(t => _handler, _validationProcessor);
              A.CallTo(() => _validationProcessor.Validate(_command)).Returns(new ValidationStatus());

              var result = commandDispatcher.Execute(_command);

              Assert.IsTrue(result.IsValid);
        }
Beispiel #5
0
 private void SetupUndoTracking(PropertyGrid propertyGrid)
 {
     if (UnixUtils.IsUnix)
     { // WORKAROUND: e.OldValue is not reliable on Mono, use MultiPropertyTracker instead
         var tracker = new MultiPropertyTracker(propertyGrid);
         propertyGrid.PropertyValueChanged += (sender, e) => CommandExecutor?.Execute(tracker.GetCommand(e.ChangedItem));
     }
     else
     {
         propertyGrid.PropertyValueChanged += (sender, e) => CommandExecutor?.Execute(new PropertyChangedCommand(Target, e));
     }
 }
        public void Execute_CallsResolverWithExpectedType()
        {
            bool wasCalledWithExpectedType = false;
              var commandDispatcher = new CommandExecutor(t =>
              {
            if (t == typeof(ICommandHandler<ICommand>))
            {
              wasCalledWithExpectedType = true;
            }
            return _handler;
              }, _validationProcessor);
              A.CallTo(() => _validationProcessor.Validate(_command)).Returns(new ValidationStatus());

              commandDispatcher.Execute(_command);

              Assert.That(wasCalledWithExpectedType, Is.True);
        }
        public void CommandExecutor_ExecuteNormalCallEmitsStartAndStopMessages()
        {
            var mockCommand = new Mock<IAdomdCommand>();
            mockCommand.Setup(p => p.Execute()).Returns(13);
            mockCommand.SetupAllProperties();
            var command = mockCommand.Object;
            var mockConnection = new Mock<IAdomdConnection>();
            var guidConnection = Guid.NewGuid();
            var glimpseCommand = new GlimpseAdomdCommand(command, mockConnection.Object, guidConnection)
            {
                CommandText = "ABC"
            };
            var mockTimedMessagePublisher = new Mock<ITimedMessagePublisher>();
            var commandExecutor = new CommandExecutor(glimpseCommand, mockTimedMessagePublisher.Object);

            var result = commandExecutor.Execute(c => c.Execute(), "Execute");

            Assert.That(result, Is.EqualTo(13));
            Assert.That(glimpseCommand.CommandId, Is.Not.Null);
            mockTimedMessagePublisher.Verify(p => p.EmitStartMessage(
                It.Is<CommandExecutedMessage>(c =>
                    c.CommandId == glimpseCommand.CommandId
                    && c.ConnectionId == guidConnection
                    && c.CommandText == "ABC"
                    && c.HasTransaction == false
                    && c.IsAsync == false
                )), Times.Once);
            mockTimedMessagePublisher.Verify(p => p.EmitStopMessage(
                It.Is<CommandDurationMessage>(c =>
                    c.CommandId == glimpseCommand.CommandId
                    && c.ConnectionId == guidConnection
                    && c.EventCategory == AdomdTimelineCategory.Command
                    && c.EventName == "Command: Executed"
                    && c.EventSubText == "Execute"
                    && c.IsAsync == false)), Times.Once);
        }
        public void CommandExecutor_ExecuteWithErrorsEmitsStartsAndStopMessages()
        {
            var mockCommand = new Mock<IAdomdCommand>();
            mockCommand.Setup(p => p.Execute()).Throws<NotSupportedException>();
            mockCommand.SetupAllProperties();
            var command = mockCommand.Object;
            var mockConnection = new Mock<IAdomdConnection>();
            var guidConnection = Guid.NewGuid();
            var glimpseCommand = new GlimpseAdomdCommand(command, mockConnection.Object, guidConnection)
                                    {
                                        CommandText = "ABC"
                                    };
            var mockTimedMessagePublisher = new Mock<ITimedMessagePublisher>();
            var commandExecutor = new CommandExecutor(glimpseCommand, mockTimedMessagePublisher.Object);

            Assert.That(() => commandExecutor.Execute(c => c.Execute(), "Execute"), Throws.InstanceOf<NotSupportedException>());

            Assert.That(glimpseCommand.CommandId, Is.Not.Null);
            mockTimedMessagePublisher.Verify(p => p.EmitStartMessage(
                It.Is<CommandExecutedMessage>(c =>
                    c.CommandId == glimpseCommand.CommandId
                    && c.ConnectionId == guidConnection
                    && c.CommandText == "ABC"
                    && c.HasTransaction == false
                    && c.IsAsync == false
                )), Times.Once);
            mockTimedMessagePublisher.Verify(p => p.EmitStopMessage(
                It.Is<CommandErrorMessage>(c =>
                    c.CommandId == glimpseCommand.CommandId
                    && c.ConnectionId == guidConnection
                    && c.Exception != null && c.Exception.GetType() == typeof(NotSupportedException)
                    && c.EventCategory == AdomdTimelineCategory.Command
                    && c.EventName == "Command: Error"
                    && c.EventSubText == "Execute"
                    && c.IsAsync == false)), Times.Once);
        }
Beispiel #9
0
 public virtual void SetOwner(string taskId, string userId)
 {
     CommandExecutor.Execute(new SetTaskOwnerCmd(taskId, userId));
 }
Beispiel #10
0
 public virtual void DeleteTask(string taskId, bool cascade)
 {
     CommandExecutor.Execute(new DeleteTaskCmd(taskId, null, cascade));
 }
        public void Execute_ValidateInvoiceCommand()
        {
            var commandDispatcher = new CommandExecutor(t => _handler, _validationProcessor);

              commandDispatcher.Execute(_command);

              A.CallTo(() => _validationProcessor.Validate(_command)).MustHaveHappened();
        }
 public virtual void DeleteCandidateStarterGroup(string processDefinitionId, string groupId)
 {
     CommandExecutor.Execute(new DeleteIdentityLinkForProcessDefinitionCmd(processDefinitionId, null, groupId));
 }
 public virtual IBpmnModelInstance GetBpmnModelInstance(string processDefinitionId)
 {
     return(CommandExecutor.Execute(new GetDeploymentBpmnModelInstanceCmd(processDefinitionId)));
 }
 public virtual Stream GetProcessDiagram(string processDefinitionId)
 {
     return(CommandExecutor.Execute(new GetDeploymentProcessDiagramCmd(processDefinitionId)));
 }
 public virtual IQueryable <IDeployment> CreateDeploymentQuery(Expression <Func <DeploymentEntity, bool> > expression)
 {
     return(CommandExecutor.Execute(new CreateQueryCmd <DeploymentEntity>(expression)));
 }
Beispiel #16
0
        public static void Main()
        {
            CommandExecutor commandExecutor = new CommandExecutor();

            commandExecutor.Execute();
        }
Beispiel #17
0
        protected override void OnRenderFrame(FrameEventArgs args)
        {
            GL.Viewport(0, 0, ClientSize.X, ClientSize.Y);
            GL.ClearColor(Color4.Beige);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            using (new SKAutoCanvasRestore(surface.Canvas, true))
            {
                // We've modified opengl state, so let's reset
                grContext.ResetContext();

                var canvas = surface.Canvas;
                canvas.Clear(new SKColor(128, 0, 128));
                //canvas.Translate(20, 20);
                //Paint.Color = new SKColor(0, 0, 200);
                //Paint.TextSize = 64;
                //canvas.DrawText("Hello", 0, 64, Paint);
                //canvas.DrawRect(0, 0, 100, 100, Paint);

                var el = new Element();
                el.Data = "root";

                el.Style.Display     = StyleDisplay.Block;
                el.Style.Position    = StylePosition.Absolute;
                el.Style.Height      = 320;
                el.Style.Width       = 220;
                el.Style.BorderWidth = 5;
                el.Style.Padding     = 5;

                Element child;
                Element box;

                var box1 = box = new Element();
                box.Data           = "b1";
                box.Style.Display  = StyleDisplay.Block;
                box.Style.Position = StylePosition.Static;
                box.Style.Width    = 20;
                box.Style.Height   = 20;
                el.AddChild(box);

                var child1 = child = new TextElement();
                child.Data                      = "child";
                child.Style.Width               = 5;
                child.Style.Height              = 30;
                child.Style.Display             = StyleDisplay.Inline;
                child.Style.Position            = StylePosition.Static;
                (child as TextElement).Content  = "Testduck Testduck2 Testduck3";
                (child as TextElement).TextSize = 20;
                el.AddChild(child);

                var box2 = box = new Element();
                box.Data           = "b1";
                box.Style.Display  = StyleDisplay.InlineBlock;
                box.Style.Position = StylePosition.Static;
                box.Style.Width    = 20;
                box.Style.Height   = 20;
                el.AddChild(box);

                var child2 = child = new TextElement();
                child.Data                      = "child2";
                child.Style.Width               = 5;
                child.Style.Height              = 30;
                child.Style.Display             = StyleDisplay.Inline;
                child.Style.Position            = StylePosition.Static;
                (child as TextElement).Content  = "Testduck4 Testduck5 Testduck6";
                (child as TextElement).TextSize = 20;
                el.AddChild(child);

                var box3 = box = new Element();
                box.Data           = "b3";
                box.Style.Display  = StyleDisplay.Block;
                box.Style.Position = StylePosition.Static;
                box.Style.Width    = 20;
                box.Style.Height   = 20;
                el.AddChild(box);

                var child3 = child = new TextElement();
                child.Data                      = "child3";
                child.Style.Height              = 30;
                child.Style.Width               = 5;
                child.Style.Display             = StyleDisplay.Inline;
                child.Style.Position            = StylePosition.Static;
                (child as TextElement).Content  = "Testduck4 Testduck5 Test|ö|└|²³|ₚ|☑|😂";
                (child as TextElement).TextSize = 20;
                el.AddChild(child);

                var layouter = new LayoutProcessor();
                layouter.ViewPort = new Box(0, 0, ClientSize.X, ClientSize.Y);
                //layouter.ViewPort = new Box(0, 0, ClientSize.X, 20);
                layouter.Process(el);

                var recorder = new CommandRecorder();
                recorder.Record(el);

                var executor = new CommandExecutor();
                executor.Execute(recorder, canvas);

                canvas.Flush();
            }

            //System.Threading.Thread.Sleep(500);

            SwapBuffers();

            var ticks  = FPSCounter.ElapsedTicks;
            var ms     = ticks / 10000.0;
            var newFPS = 1000f / (float)ms;

            FPSCounter.Restart();
            CurrentFPS = Smooth(CurrentFPS, newFPS, 0.01f);
            if ((DateTime.UtcNow - LastUpdatedFPS).TotalSeconds > 1)
            {
                LastUpdatedFPS = DateTime.UtcNow;
                Title          = $"FPS: {CurrentFPS.ToString("F0", CultureInfo.CurrentCulture)}";
            }
        }
Beispiel #18
0
 /// <summary>
 /// Обработчик выполения команды пункта меню
 /// </summary>
 protected void item_ItemClick(object sender, ItemClickEventArgs e)
 {
     Application.DoEvents();
     CommandExecutor.Execute(e.Item.Tag as ICommand);
 }
Beispiel #19
0
 public virtual void DeleteCandidateGroup(string taskId, string groupId)
 {
     CommandExecutor.Execute(new DeleteGroupIdentityLinkCmd(taskId, groupId, IdentityLinkType.Candidate));
 }
Beispiel #20
0
 public virtual void AddGroupIdentityLink(string taskId, string groupId, string identityLinkType)
 {
     CommandExecutor.Execute(new AddGroupIdentityLinkCmd(taskId, groupId, identityLinkType));
 }
Beispiel #21
0
 public virtual void AddUserIdentityLink(string taskId, string userId, string identityLinkType)
 {
     CommandExecutor.Execute(new AddUserIdentityLinkCmd(taskId, userId, identityLinkType));
 }
Beispiel #22
0
 public virtual void AddCandidateUser(string taskId, string userId)
 {
     CommandExecutor.Execute(new AddUserIdentityLinkCmd(taskId, userId, IdentityLinkType.Candidate));
 }
 public virtual Stream GetResourceAsStream(string deploymentId, string resourceName)
 {
     return(CommandExecutor.Execute(new GetDeploymentResourceCmd(deploymentId, resourceName)));
 }
 public virtual Stream GetResourceAsStreamById(string deploymentId, string resourceId)
 {
     return(CommandExecutor.Execute(new GetDeploymentResourceForIdCmd(deploymentId, resourceId)));
 }
Beispiel #25
0
        public IActionResult CreatePopulation(CreatePopulationCommand command)
        {
            var createPopulationResult = _commandExecutor.Execute(command);

            return(RedirectToAction("PopulationListing"));
        }
 public virtual IProcessDefinition GetProcessDefinition(string processDefinitionId)
 {
     return
         ((IProcessDefinition)
          CommandExecutor.Execute(new GetDeployedProcessDefinitionCmd(processDefinitionId, true)));
 }
 /// <inheritdoc />
 public object Execute()
 {
     return _commandExecutor.Execute((p => p.Execute()), "Execute");
 }
 public virtual DiagramLayout GetProcessDiagramLayout(string processDefinitionId)
 {
     return(CommandExecutor.Execute(new GetDeploymentProcessDiagramLayoutCmd(processDefinitionId)));
 }
Beispiel #29
0
 public virtual void DeleteTasks(ICollection <string> taskIds, string deleteReason)
 {
     CommandExecutor.Execute(new DeleteTaskCmd(taskIds, deleteReason, false));
 }
 public virtual void AddCandidateStarterUser(string processDefinitionId, string userId)
 {
     CommandExecutor.Execute(new AddIdentityLinkForProcessDefinitionCmd(processDefinitionId, userId, null));
 }
 public virtual IQueryable <IDecisionRequirementsDefinition> CreateDecisionRequirementsDefinitionQuery(Expression <Func <DecisionRequirementsDefinitionEntity, bool> > expression)
 {
     return(CommandExecutor.Execute(new CreateQueryCmd <DecisionRequirementsDefinitionEntity>(expression)));
 }
Beispiel #32
0
 public virtual void DeleteTask(string taskId, string deleteReason)
 {
     CommandExecutor.Execute(new DeleteTaskCmd(taskId, deleteReason, false));
 }
 public virtual IList <string> GetDeploymentResourceNames(string deploymentId)
 {
     return(CommandExecutor.Execute(new GetDeploymentResourceNamesCmd(deploymentId)));
 }
Beispiel #34
0
 public virtual void DeleteTasks(ICollection <string> taskIds, bool cascade)
 {
     CommandExecutor.Execute(new DeleteTaskCmd(taskIds, null, cascade));
 }
 public virtual IList <IResource> GetDeploymentResources(string deploymentId)
 {
     return(ListExt.ConvertToListT <IResource>(CommandExecutor.Execute(new GetDeploymentResourcesCmd(deploymentId))));
 }
Beispiel #36
0
        public ChangeSiteCommand(Website old, Website website)
        {
            Tasks = new Queue <CassiniTask>();

            Tasks.Enqueue(
                new CassiniTask
            {
                Text     = "Validating input..",
                Argument = website,
                Work     = (arg) =>
                {
                    if (website.Port != old.Port && !new WebsiteHost(website).IsPortUsable())
                    {
                        Cancel(new PortInUseException());
                    }

                    if (old.Url != website.Url && App.WebSiteHosts.ContainsKey(website.Url))
                    {
                        Cancel(new WebsiteExistsAtTheSameUrl());
                    }

                    return(CassiniTaskResult.NoResult);
                }
            });

            Tasks.Enqueue(
                new CassiniTask
            {
                Text     = "Stopping website..",
                Argument = website,
                Work     = (arg) =>
                {
                    CommandExecutor.Execute(new DeleteSiteCommand(old));

                    return(CassiniTaskResult.NoResult);
                }
            });

            Tasks.Enqueue(
                new CassiniTask
            {
                Text     = "Confuguring website..",
                Argument = website,
                Work     = (arg) =>
                {
                    CommandExecutor.Execute(new HostSiteCommand(website));
                    return(CassiniTaskResult.NoResult);
                }
            });

            Tasks.Enqueue(
                new CassiniTask
            {
                Text     = "Setting up website..",
                Argument = website,
                Work     = (arg) =>
                {
                    App.RaiseEvent(EventKeys.WEBSITE_CHANGED, this, new EventBrokerEventArgs(website));
                    return(CassiniTaskResult.NoResult);
                }
            });
        }
Beispiel #37
0
 public virtual void SetAssignee(string taskId, string userId)
 {
     CommandExecutor.Execute(new AssignTaskCmd(taskId, userId));
 }
        public void Execute_QueryHandlerResolved_CallsHandleMethod()
        {
            var commandDispatcher = new CommandExecutor(t => _handler, _validationProcessor);
              A.CallTo(() => _validationProcessor.Validate(_command)).Returns(new ValidationStatus());

              commandDispatcher.Execute(_command);

              _handler.CallsTo(m => m.Handle(_command)).MustHaveHappened(Repeated.Exactly.Once);
        }
Beispiel #39
0
 public void Execute(CommandExecutor executor)
 {
     executor.Execute(this);
 }