示例#1
0
        public void CallingExternalDataExchangeFromWindsor()
        {
            _container.AddComponent("testingexternaldata.service", typeof(ITestingExternalData), typeof(TestingExternalData));

            WorkflowRuntime runtime = _container.Resolve <WorkflowRuntime>();

            ManualResetEvent finished = new ManualResetEvent(false);
            string           fullName = null;

            runtime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
            {
                fullName = Convert.ToString(e.OutputParameters["FullName"]);
                finished.Set();
            };
            runtime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { finished.Set(); };

            WorkflowInstance workflow = runtime.CreateWorkflow(typeof(CreateNameWorkflow));

            workflow.Start();
            bool isFinished = finished.WaitOne(TimeSpan.FromSeconds(1), false);

            Assert.IsTrue(isFinished, "Workflow must finish in less than a second");

            Assert.AreEqual("hello world", fullName, "Full name must be set with default values");

            TestingExternalData testingExternalData = (TestingExternalData)_container.Resolve <ITestingExternalData>();

            Assert.AreEqual("hello world", testingExternalData.MostRecentFullName, "Container must return the singleton the workflow used to call method");
        }
示例#2
0
        public void RaisingEventFromExternalDataExchange()
        {
            _container.AddComponent("testingexternaldata.service", typeof(ITestingExternalData), typeof(TestingExternalData));

            WorkflowRuntime runtime = _container.Resolve <WorkflowRuntime>();

            ManualResetEvent finished = new ManualResetEvent(false);

            runtime.WorkflowCompleted  += delegate(object sender, WorkflowCompletedEventArgs e) { finished.Set(); };
            runtime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e) { finished.Set(); };

            WorkflowInstance workflow = runtime.CreateWorkflow(typeof(PausingWorkflow));

            workflow.Start();
            bool isFinished = finished.WaitOne(TimeSpan.FromSeconds(.25), false);

            Assert.IsFalse(isFinished, "Workflow must not be finished yet");

            TestingExternalData testingExternalData = (TestingExternalData)_container.Resolve <ITestingExternalData>();

            testingExternalData.OnSurveyComplete(workflow.InstanceId, "a test name");

            isFinished = finished.WaitOne(TimeSpan.FromSeconds(1), false);
            Assert.IsTrue(isFinished, "Workflow must finish in less than a second");

            Assert.AreEqual("a test name called", testingExternalData.MostRecentFullName, "Workflow was supposed to call back with the value the test provided");
        }
示例#3
0
        public void ComponentsProvidedByConfiguration()
        {
            WorkflowRuntime  runtime  = _container.Resolve <WorkflowRuntime>();
            WorkflowInstance instance = runtime.CreateWorkflow(typeof(CreateNameWorkflow));

            instance.Start();

            ManualWorkflowSchedulerService scheduler = _container.Resolve <ManualWorkflowSchedulerService>();

            scheduler.RunWorkflow(instance.InstanceId);

            TestingExternalData testingExternalData = (TestingExternalData)_container.Resolve <ITestingExternalData>();

            Assert.AreEqual("You are \"{0} {1}\".", testingExternalData.FullNameFormat, "Format must have been provided by config");
            Assert.AreEqual("You are \"hello world\".", testingExternalData.MostRecentFullName, "Full name must have been set by workflow execution");
        }