Exemple #1
0
        public void SCFileScopeWithSharedContextGetInsideException()
        {
            string aFileName = this.ClearEnvironmentForTest();

            var sharedContextScopeActivity = new ClientScopeActivity
            {
                ContextName = Test_ContextName,
                ContextType = Test_ContextType,
                Retries     = Test_Retries
            };

            var getContextActivity = new GetVariableActivity
            {
                VariableName   = Test_SetVariableName,
                RaiseException = true
            };

            sharedContextScopeActivity.Body.Handler = new Sequence()
            {
                Activities =
                {
                    getContextActivity
                }
            };

            try
            {
                var output = WorkflowInvoker.Invoke(sharedContextScopeActivity);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message == "[SharedContext Client] Variable Name " + Test_SetVariableName + " does not exist in context " + Test_ContextName);
            }
        }
Exemple #2
0
        public void NewThread()
        {
            Console.WriteLine("In thread > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
            string aFileName = ClearEnvironmentForTest(true);

            var sharedContextScopeActivity = new ClientScopeActivity
            {
                ContextName = Test_ContextName,
                ContextType = Test_ContextType,
                Retries     = Test_Retries
            };

            var setContextActivity = new SetVariableActivity
            {
                VariableName  = Test_SetVariableName,
                VariableValue = Test_SetVariableValue
            };

            sharedContextScopeActivity.Body.Handler = new Sequence()
            {
                Activities =
                {
                    setContextActivity
                }
            };

            Console.WriteLine("In thread : about to execute > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
            var output = WorkflowInvoker.Invoke(sharedContextScopeActivity);
        }
Exemple #3
0
        public void SCFileScopeWithSharedContextSetInside()
        {
            string aFileName = this.ClearEnvironmentForTest();

            var sharedContextScopeActivity = new ClientScopeActivity
            {
                ContextName = Test_ContextName,
                ContextType = Test_ContextType,
                Retries     = Test_Retries
            };

            var setContextActivity = new SetVariableActivity
            {
                VariableName  = Test_SetVariableName,
                VariableValue = Test_SetVariableValue
            };

            sharedContextScopeActivity.Body.Handler = new Sequence()
            {
                Activities =
                {
                    setContextActivity
                }
            };

            var output = WorkflowInvoker.Invoke(sharedContextScopeActivity);

            Assert.IsTrue(File.Exists(aFileName));
            string fileContents = File.ReadAllText(aFileName);

            Assert.IsTrue(fileContents == "{\"GlobalVariables\":{\"aVariable123\":\"aValue456\"},\"Messages\":{}}");
        }
Exemple #4
0
        public void SCFileScopeWithSharedContextGetInside()
        {
            string aFileName = this.ClearEnvironmentForTest();

            var sharedContextScopeActivity = new ClientScopeActivity
            {
                ContextName = Test_ContextName,
                ContextType = Test_ContextType,
                Retries     = Test_Retries
            };

            var getContextActivity = new GetVariableActivity
            {
                VariableName   = Test_SetVariableName,
                RaiseException = false
            };

            sharedContextScopeActivity.Body.Handler = new Sequence()
            {
                Activities =
                {
                    getContextActivity
                }
            };

            var output = WorkflowInvoker.Invoke(sharedContextScopeActivity);

            Assert.IsTrue(output["OutputContextFile"].ToString() == aFileName);
        }
Exemple #5
0
        public void NewThread()
        {
            Console.WriteLine("In thread > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
            var aContextServer = this.SetUpContextServer();

            var sharedContextScopeActivity = new ClientScopeActivity
            {
                ContextName  = Test_ContextName,
                ContextType  = Test_ContextType,
                ClearContext = true,
                Retries      = Test_Retries
            };

            var setContextActivity = new SetVariableActivity
            {
                VariableName  = Test_SetVariableName,
                VariableValue = Test_SetVariableValue
            };

            sharedContextScopeActivity.Body.Handler = new Sequence()
            {
                Activities =
                {
                    setContextActivity
                }
            };

            Console.WriteLine("In thread : about to execute > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
            WorkflowInvoker.Invoke(sharedContextScopeActivity);

            aContextServer.MyDispose();
        }
Exemple #6
0
        public void SCNamedPipeTryToOpenLockedContext()
        {
            Thread thread1 = new Thread(NewThread);

            thread1.Start();
            for (int i = 0; i < 5; i++)
            {
                Console.WriteLine("In main. i=" + i.ToString() + " > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));

                if (i == 0 || i == 3)
                {
                    try
                    {
                        var sharedContextScopeActivity = new ClientScopeActivity
                        {
                            ContextName = Test_ContextName,
                            ContextType = Test_ContextType,
                            Retries     = Test_Retries
                        };

                        var setContextActivity = new SetVariableActivity
                        {
                            VariableName  = Test_SetVariableName,
                            VariableValue = Test_SetVariableValue
                        };

                        sharedContextScopeActivity.Body.Handler = new Sequence()
                        {
                            Activities =
                            {
                                setContextActivity
                            }
                        };

                        var output = WorkflowInvoker.Invoke(sharedContextScopeActivity);

                        Console.WriteLine("File locked! > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
                        Thread.Sleep(200);
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Could not lock File > " + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fffff tt"));
                        Thread.Sleep(50);
                    }
                }
                Thread.Sleep(200);
            }
        }
Exemple #7
0
        public void SCNamedPipeScopeWithSharedContextSetGetInside()
        {
            var sharedContextServerScope = new ServerScopeActivity
            {
                ContextName = Test_ContextName
            };

            var sharedContextScopeActivity = new ClientScopeActivity
            {
                ContextName  = Test_ContextName,
                ContextType  = Test_ContextType,
                ClearContext = true,
                Retries      = Test_Retries
            };

            var setContextActivity = new SetVariableActivity
            {
                VariableName  = Test_SetVariableName,
                VariableValue = Test_SetVariableValue
            };

            var getContextActivity = new GetVariableActivity
            {
                VariableName = Test_SetVariableName
            };

            sharedContextServerScope.Body.Handler = new Sequence()
            {
                Activities =
                {
                    sharedContextScopeActivity
                }
            };

            sharedContextScopeActivity.Body.Handler = new Sequence()
            {
                Activities =
                {
                    setContextActivity,
                    getContextActivity
                }
            };

            var output = WorkflowInvoker.Invoke(sharedContextServerScope);
        }
Exemple #8
0
        public void SCNamedPipeTryToOpenTwoContextScopes()
        {
            var aContextServer = this.SetUpContextServer();

            var sharedContextScopeActivityInner = new ClientScopeActivity
            {
                ContextName  = Test_ContextName,
                ContextType  = Test_ContextType,
                ClearContext = true,
                Retries      = Test_Retries
            };

            var sharedContextScopeActivityOuter = new ClientScopeActivity
            {
                ContextName  = Test_ContextName,
                ContextType  = Test_ContextType,
                ClearContext = true,
                Retries      = Test_Retries
            };

            sharedContextScopeActivityOuter.Body.Handler = new Sequence()
            {
                Activities =
                {
                    sharedContextScopeActivityInner
                }
            };

            try
            {
                var output = WorkflowInvoker.Invoke(sharedContextScopeActivityOuter);
            }
            catch (Exception e)
            {
                Assert.IsTrue(e.Message == "[SharedContext Client] Could not open resource within the retries.");
            }
            aContextServer.MyDispose();
        }
Exemple #9
0
        public void SCFileScopeWithClearInside()
        {
            string aFileName = this.ClearEnvironmentForTest();

            var sharedContextScopeActivity = new ClientScopeActivity
            {
                ContextName  = Test_ContextName,
                ContextType  = Test_ContextType,
                Retries      = Test_Retries,
                ClearContext = true
            };

            sharedContextScopeActivity.Body.Handler = new Sequence()
            {
                Activities =
                {
                }
            };

            var output = WorkflowInvoker.Invoke(sharedContextScopeActivity);

            Assert.IsTrue(output["OutputContextFile"].ToString() == aFileName);
            Assert.IsTrue(File.ReadAllText(aFileName) == "{\"GlobalVariables\":{},\"Messages\":{}}");
        }