public void WorkflowDesignerUtils_ShowExampleWorkflow_DsfDateTime_DateTimeExampleShown() { const string expectedResourceName = "Example - DateTime"; var aggregator = new Mock <EventAggregator>(); IResourceModel actualResourceInvoked = null; aggregator.Setup(a => a.Publish(It.IsAny <AddWorkSurfaceMessage>())).Callback <object>(msg => { var workSurfaceObject = (msg is AddWorkSurfaceMessage) ? (msg as AddWorkSurfaceMessage).WorkSurfaceObject : null; actualResourceInvoked = (workSurfaceObject is IResourceModel) ? (workSurfaceObject as IResourceModel) : null; }); EventPublishers.Aggregator = aggregator.Object; var mockedResourceRepo = new Mock <IResourceRepository>(); var mockedEnvironment = new Mock <IEnvironmentModel>(); var mockedExampleWorkflow = new Mock <IResourceModel>(); mockedExampleWorkflow.Setup(res => res.DisplayName).Returns(expectedResourceName); mockedResourceRepo.Setup(repo => repo.FindSingle(It.IsAny <Expression <Func <IResourceModel, bool> > >(), false)).Returns(mockedExampleWorkflow.Object); mockedEnvironment.Setup(env => env.ResourceRepository).Returns(mockedResourceRepo.Object); //------------Execute Test--------------------------- WorkflowDesignerUtils.ShowExampleWorkflow("DsfDateTimeActivity", mockedEnvironment.Object, null); // Assert MultiAssign example shown Assert.AreEqual(expectedResourceName, actualResourceInvoked.DisplayName, "Example for DateTime tool not shown"); }
public void WorkflowDesignerUtils_ShowExampleWorkflow_DsfMultiAssignExampleResourceNotFound_MultiAssignExampleShown() { var mockedResourceRepo = new Mock <IResourceRepository>(); var mockedEnvironment = new Mock <IEnvironmentModel>(); var popupController = new MoqPopup(MessageBoxResult.OK); mockedEnvironment.Setup(env => env.ResourceRepository).Returns(mockedResourceRepo.Object); //------------Execute Test--------------------------- WorkflowDesignerUtils.ShowExampleWorkflow("DsfMultiAssignActivity", mockedEnvironment.Object, popupController); // Assert MultiAssign example shown Assert.AreEqual(1, popupController.ShowHitCount, "Info messagebox not shown when example workflow not found"); }
static Action <Type> CreateShowExampleWorkflowAction() { return(type => WorkflowDesignerUtils.ShowExampleWorkflow(type.Name, ServerUtil.GetLocalhostServer(), null)); }