示例#1
0
        private static void RunUpdateBuildNumberInTestCodeActivityUsingWorkflowApplication(IBuildDetail mockBuildDetail)
        {
            // Variables - in
            Variable <string> buildNumberFormat = new Variable <string>("BuildNumberFormat", "Acme.PetShop-Trunk-Full-{0}");
            Variable <int>    majorVersion      = new Variable <int>("MajorVersion", 1);
            Variable <int>    minorVersion      = new Variable <int>("MinorVersion", 0);

            // Variables - out
            Variable <string> buildNumber   = new Variable <string>("BuildNumber");
            Variable <string> versionNumber = new Variable <string>("VersionNumber");

            // Activities
            GetBuildDetail    getBuildDetail    = new GetBuildDetail();
            UpdateBuildNumber updateBuildNumber = new UpdateBuildNumber
            {
                BuildNumberFormat = buildNumberFormat,
                MajorVersion      = majorVersion,
                MinorVersion      = minorVersion,
                BuildNumber       = buildNumber,
                VersionNumber     = versionNumber
            };

            // Sequence
            Sequence sequence = new Sequence();

            sequence.Variables.Add(buildNumberFormat);
            sequence.Variables.Add(majorVersion);
            sequence.Variables.Add(minorVersion);
            sequence.Variables.Add(buildNumber);
            sequence.Variables.Add(versionNumber);
            sequence.Activities.Add(getBuildDetail);
            sequence.Activities.Add(updateBuildNumber);

            // Run
            WorkflowApplication workflowApplication = new WorkflowApplication(sequence);

            workflowApplication.Extensions.Add(mockBuildDetail);
            AutoResetEvent idleEvent = new AutoResetEvent(false);

            workflowApplication.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
            {
                idleEvent.Set();
            };

            workflowApplication.Run();
            idleEvent.WaitOne();
        }
        private static void RunUpdateBuildNumberInTestCodeActivityUsingWorkflowApplication(IBuildDetail mockBuildDetail)
        {
            // Variables - in
            Variable<string> buildNumberFormat = new Variable<string>("BuildNumberFormat", "Acme.PetShop-Trunk-Full-{0}");
            Variable<int> majorVersion = new Variable<int>("MajorVersion", 1);
            Variable<int> minorVersion = new Variable<int>("MinorVersion", 0);

            // Variables - out
            Variable<string> buildNumber = new Variable<string>("BuildNumber");
            Variable<string> versionNumber = new Variable<string>("VersionNumber");

            // Activities
            GetBuildDetail getBuildDetail = new GetBuildDetail();
            UpdateBuildNumber updateBuildNumber = new UpdateBuildNumber
                {
                    BuildNumberFormat = buildNumberFormat,
                    MajorVersion = majorVersion,
                    MinorVersion = minorVersion,
                    BuildNumber = buildNumber,
                    VersionNumber = versionNumber
                };

            // Sequence
            Sequence sequence = new Sequence();
            sequence.Variables.Add(buildNumberFormat);
            sequence.Variables.Add(majorVersion);
            sequence.Variables.Add(minorVersion);
            sequence.Variables.Add(buildNumber);
            sequence.Variables.Add(versionNumber);
            sequence.Activities.Add(getBuildDetail);
            sequence.Activities.Add(updateBuildNumber);

            // Run
            WorkflowApplication workflowApplication = new WorkflowApplication(sequence);
            workflowApplication.Extensions.Add(mockBuildDetail);
            AutoResetEvent idleEvent = new AutoResetEvent(false);
            workflowApplication.Completed = delegate(WorkflowApplicationCompletedEventArgs e)
                {
                    idleEvent.Set();
                };

            workflowApplication.Run();
            idleEvent.WaitOne();
        }