Ejemplo n.º 1
0
        public void DsfActivity_OnExecute_WhenIsTestExecutionShouldUpdateDataObject_SetBackToTrue()
        {
            //------------Setup for test--------------------------
            var environmentID = Guid.Empty;
            var dataObject    = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentID,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };
            var resourceID = Guid.NewGuid();

            var act = new DsfActivity
            {
                ResourceID    = new InArgument <Guid>(resourceID),
                EnvironmentID = Guid.Empty
            };
            var mockAutorizationService = new Mock <IAuthorizationService>();

            mockAutorizationService.Setup(service => service.IsAuthorized(It.IsAny <IPrincipal>(), AuthorizationContext.Execute, resourceID.ToString())).Returns(true);

            var p = new PrivateObject(act);

            p.SetProperty("AuthorizationService", mockAutorizationService.Object);

            //------------Execute Test---------------------------
            TestStartNode = new FlowStep
            {
                Action = act
            };

            TestData  = "<DataList></DataList>";
            CurrentDl = "<DataList></DataList>";
            User      = new Mock <IPrincipal>().Object;
            ExecuteProcess(dataObject, true, null, false, true, false, environmentID);
            //------------Assert Results-------------------------
            Assert.IsTrue(dataObject.IsServiceTestExecution);
        }
        public void SharepointSource_Exists_OnResourceCatalog_BlankRecordSet()
        {
            //------------Setup for test--------------------------
            const string activityName = "SharepointCopyFile";
            var          resourceId   = Guid.NewGuid();
            var          sharepointCopyFileActivity = new SharepointCopyFileActivity
            {
                DisplayName = activityName,
                SharepointServerResourceId = resourceId,
                Result = "[[Files().Name]]",
                ServerInputPathFrom = @"C:\ProgramData\Warewolf\Resources\Hello World.bite",
                ServerInputPathTo   = "Hello World.bite",
                Overwrite           = true
            };

            var dataObj = new DsfDataObject("", Guid.NewGuid(), "");

            var resourceCatalog = new Mock <IResourceCatalog>();

            var mockSharepointHelper = new Mock <ISharepointHelper>();

            mockSharepointHelper.Setup(helper => helper.CopyFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).Returns("Success");

            var mockSharepointSource = new MockSharepointSource
            {
                MockSharepointHelper = mockSharepointHelper.Object
            };

            resourceCatalog.Setup(r => r.GetResource <SharepointSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(mockSharepointSource);

            var privateObject = new PrivateObject(sharepointCopyFileActivity);

            privateObject.SetProperty("ResourceCatalog", resourceCatalog.Object);
            sharepointCopyFileActivity.SharepointSource = mockSharepointSource;

            //------------Execute Test---------------------------
            privateObject.Invoke("ExecuteTool", dataObj, 0);
            //------------Assert Result--------------------------
            GetRecordSetFieldValueFromDataList(dataObj.Environment, "Files", "Name", out IList <string> result, out string error);
            Assert.IsNotNull(result);
            Assert.AreEqual("Success", result[0]);
        }
Ejemplo n.º 3
0
        public void DsfWebGetRequestWithTimeoutActivity_ExecuteRequest_WithError_ExpectTimeOut_IsTrue()
        {
            //------------Setup for test--------------------------
            const string Message = "This is a forced exception";

            var mock          = new Mock <IWebRequestInvoker>();
            var dsfDataObject = new DsfDataObject("", Guid.NewGuid());
            var errorResultTO = new ErrorResultTO();


            var environment = new ExecutionEnvironment();

            var activity = GetWebGetRequestWithTimeoutActivity(mock);

            activity.Method      = "GET";
            activity.Url         = "BodyValue";
            activity.TimeOutText = "-1";

            TestStartNode = new FlowStep
            {
                Action = activity
            };

            mock.Setup(invoker => invoker.ExecuteRequest(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <List <Tuple <string, string> > >(), It.IsAny <int>())).Throws(new InvalidDataException(Message));

            environment.Assign("[[URL]]", "http://rsaklfsvrtfsbld:9910/api/values", 0);

            dsfDataObject.Environment = environment;
            dsfDataObject.IsDebug     = true;
            dsfDataObject.EsbChannel  = new MockEsb();

            bool          timeoutSecondsError = false;
            PrivateObject obj = new PrivateObject(activity);

            object[] args = new object[] { dsfDataObject, 0, errorResultTO, timeoutSecondsError };

            //------------Execute Test---------------------------
            var act = obj.Invoke("SetTimeoutSecondsError", args);

            //------------Assert Results-------------------------
            Assert.AreEqual(true, act);
        }
Ejemplo n.º 4
0
        public void DsfWebPutActivity_Execute_ErrorResponse_ShouldSetVariables()
        {
            //------------Setup for test--------------------------
            const string response          = "{\"Message\":\"Error\"}";
            var          dsfWebPutActivity = new DsfWebPutActivity();

            dsfWebPutActivity.ResourceID = InArgument <Guid> .FromValue(Guid.Empty);

            var mockResourceCatalog = new Mock <IResourceCatalog>();
            var webSource           = new WebSource
            {
                Address            = $"http://{Depends.TFSBLDIP}:9910/api/",
                AuthenticationType = AuthenticationType.Anonymous
            };

            mockResourceCatalog.Setup(resCat => resCat.GetResource <WebSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(webSource);
            dsfWebPutActivity.ResourceCatalog = mockResourceCatalog.Object;
            var serviceOutputs = new List <IServiceOutputMapping> {
                new ServiceOutputMapping("Message", "[[Message]]", "")
            };

            dsfWebPutActivity.Outputs = serviceOutputs;
            var serviceXml = XmlResource.Fetch("WebService");
            var service    = new WebService(serviceXml)
            {
                RequestResponse = response
            };

            dsfWebPutActivity.OutputDescription = service.GetOutputDescription();

            dsfWebPutActivity.QueryString = "Error";

            dsfWebPutActivity.SourceId = Guid.Empty;
            dsfWebPutActivity.Headers  = new List <INameValue>();
            var dataObject = new DsfDataObject("", Guid.NewGuid());

            dataObject.EsbChannel = new MockEsb();
            //------------Execute Test---------------------------
            dsfWebPutActivity.Execute(dataObject, 0);
            //------------Assert Results-------------------------
            Assert.AreEqual("Error", ExecutionEnvironment.WarewolfEvalResultToString(dataObject.Environment.Eval("[[Message]]", 0)));
        }
Ejemplo n.º 5
0
        public void DsfNativeActivity_DispatchDebugState_After_SetsEndTimeCorrectly()
        {
            var             parentInstanceID = Guid.NewGuid();
            const StateType StateType        = StateType.After;

            var dataObj = new DsfDataObject(string.Empty, GlobalConstants.NullDataListID)
            {
                IsDebug = true,
                IsOnDemandSimulation = false,
                EnvironmentID        = Guid.NewGuid(),
                WorkspaceID          = Guid.NewGuid(),
                ServerID             = Guid.NewGuid(),
                ResourceID           = Guid.NewGuid(),
                OriginalInstanceID   = Guid.NewGuid(),
                ParentInstanceID     = parentInstanceID.ToString()
            };
            IDebugState passedDebugState    = null;
            var         mockDebugDispatcher = new Mock <IDebugDispatcher>();

            mockDebugDispatcher.Setup(dispatcher => dispatcher.Write(It.IsAny <IDebugState>(), It.IsAny <bool>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <IList <IDebugState> >()))
            .Callback((IDebugState ds, bool isTestExecution, bool isDebugFromWeb, string testName, bool isRemoteInvoke, string remoteID, string parentId, IList <IDebugState> remoteItems) =>
            {
                passedDebugState = ds;
            });
            var activity = new TestActivity(mockDebugDispatcher.Object)
            {
                IsSimulationEnabled = false,
                ScenarioID          = Guid.NewGuid().ToString(),
                IsWorkflow          = true,
            };
            var cat = new Mock <IResourceCatalog>();
            var res = new Mock <IResource>();

            res.Setup(a => a.ResourceName).Returns("bob");
            cat.Setup(a => a.GetResource(Guid.Empty, It.IsAny <Guid>())).Returns(res.Object);
            activity.ResourceCatalog = cat.Object;
            activity.TestDispatchDebugState(dataObj, StateType);
            Assert.IsNotNull(passedDebugState);
            Assert.IsNotNull(passedDebugState.EndTime);
            Assert.AreNotEqual(DateTime.MinValue, passedDebugState.StartTime);
            Assert.AreNotEqual(DateTime.MinValue, passedDebugState.EndTime);
        }
Ejemplo n.º 6
0
// ReSharper disable InconsistentNaming
        public void DsfForEach_UpdateDebugParentID_UniqueIdNotSameIfNestingLevelIncreased()
// ReSharper restore InconsistentNaming
        {
            var dataObject = new DsfDataObject(CurrentDl, Guid.NewGuid())
            {
                // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID
                //       if this is NOT provided which will cause the tests to fail!
                ServerID            = Guid.NewGuid(),
                IsDebug             = true,
                ForEachNestingLevel = 1
            };

            DsfForEachActivity act = new DsfForEachActivity();
            var originalGuid       = Guid.NewGuid();

            act.UniqueID = originalGuid.ToString();
            act.UpdateDebugParentID(dataObject);
            Assert.AreNotEqual(originalGuid.ToString(), act.UniqueID);
            Assert.AreEqual(act.GetWorkSurfaceMappingId(), originalGuid);
        }
Ejemplo n.º 7
0
        public void DsfNativeActivity_UpdateDebugParentID_UniqueIdNotSameIfNestingLevelIncreased()

        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID
                //       if this is NOT provided which will cause the tests to fail!
                ServerID            = Guid.NewGuid(),
                IsDebug             = true,
                ForEachNestingLevel = 1
            };

            var act          = new TestNativeActivity(false, "bob");
            var originalGuid = Guid.NewGuid();

            act.UniqueID = originalGuid.ToString();
            act.UpdateDebugParentID(dataObject);
            Assert.AreEqual(originalGuid.ToString(), act.UniqueID);
            Assert.AreEqual(act.GetWorkSurfaceMappingId(), originalGuid);
        }
        public void ExecutionEnvironmentUtils_GetJsonOutputFromEnvironment_WhenDataList_ShouldOnlyHaveVariablesMarkedAsOutputInString()
        {
            //------------Setup for test--------------------------
            var          dataObj  = new DsfDataObject(string.Empty, Guid.NewGuid());
            const string dataList = "<DataList>" +
                                    "<Name Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Input\"/>" +
                                    "<Surname Description=\"\" IsEditable=\"True\" ColumnIODirection=\"None\"/>" +
                                    "<FullName Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\"/>" +
                                    "<Age Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\"/>" +
                                    "<Salary Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\"/>" +
                                    "<rec Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\">" +
                                    "<a Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\" />" +
                                    "<b Description=\"\" IsEditable=\"True\" ColumnIODirection=\"None\" />" +
                                    "<c Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Input\" />" +
                                    "</rec>" +
                                    "</DataList>";

            dataObj.Environment.Assign("[[rec().a]]", "1", 0);
            dataObj.Environment.Assign("[[rec().b]]", "2", 0);
            dataObj.Environment.Assign("[[rec().c]]", "3", 0);
            dataObj.Environment.Assign("[[Name]]", "Bob", 0);
            dataObj.Environment.Assign("[[Surname]]", "Mary", 0);
            dataObj.Environment.Assign("[[FullName]]", "Bob Mary", 0);
            dataObj.Environment.Assign("[[Age]]", "15", 0);
            dataObj.Environment.Assign("[[Salary]]", "1550.55", 0);
            //------------Execute Test---------------------------
            var actual = ExecutionEnvironmentUtils.GetJsonOutputFromEnvironment(dataObj, dataList, 0);

            //------------Assert Results-------------------------
            StringAssert.Contains(actual, "rec");
            StringAssert.Contains(actual, "\"a\": 1");
            StringAssert.Contains(actual, "\"a\": \"\"");
            StringAssert.Contains(actual, "\"a\": \"\"");
            StringAssert.Contains(actual, "\"FullName\": \"Bob Mary\"");
            StringAssert.Contains(actual, "\"Age\": 15");
            StringAssert.Contains(actual, "\"Salary\": 1550.55");
            Assert.IsFalse(actual.Contains("\"Name\": \"Bob\""));
            Assert.IsFalse(actual.Contains("\"Surname\": \"Mary\""));
            Assert.IsFalse(actual.Contains("\"b\": \"2\""));
            Assert.IsFalse(actual.Contains("\"c\": \"3\""));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// The ForEach Activity requires the data returned from an activity
        /// We will mock the DSF channel to return something that we expect is shaped.
        /// </summary>
        /// <returns></returns>
        public void ExecuteForEachProcessForReal(out IDSFDataObject dataObject)
        {
            var svc = new ServiceAction {
                Name = "ForEachTestAction", ServiceName = "UnitTestService"
            };
            IEsbChannel channel = new EsbServicesEndpoint();

            svc.SetActivity(FlowchartProcess);

            if (CurrentDl == null)
            {
                CurrentDl = TestData;
            }

            Compiler = DataListFactory.CreateDataListCompiler();
            ErrorResultTO errors;
            Guid          exId = Compiler.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), new StringBuilder(TestData), new StringBuilder(CurrentDl), out errors);


            if (errors.HasErrors())
            {
                string errorString = errors.FetchErrors().Aggregate(string.Empty, (current, item) => current + item);

                throw new Exception(errorString);
            }

            dataObject = new DsfDataObject(CurrentDl, exId)
            {
                // NOTE: WorkflowApplicationFactory.InvokeWorkflowImpl() will use HostSecurityProvider.Instance.ServerID
                //       if this is NOT provided which will cause the tests to fail!
                ServerID       = Guid.NewGuid(),
                ParentThreadID = 1
            };


            // we need to set this now ;)
            WfExecutionContainer wfec = new WfExecutionContainer(svc, dataObject, Dev2.Workspaces.WorkspaceRepository.Instance.ServerWorkspace, channel);

            errors.ClearErrors();
            dataObject.DataListID = wfec.Execute(out errors);
        }
Ejemplo n.º 10
0
        public void PopEnvironment_GivenHasNoEnvironments_ShouldNotSetEnvironment()
        {
            //---------------Set up test pack-------------------
            var mock = new Mock <IExecutionEnvironment>();

            mock.SetupAllProperties();
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.NewGuid());

            dataObject.Environment = mock.Object;
            var privateObject = new PrivateObject(dataObject);
            var field         = privateObject.GetField("_environments", BindingFlags.Instance | BindingFlags.NonPublic) as ConcurrentStack <IExecutionEnvironment>;

            //---------------Assert Precondition----------------
            Assert.IsNotNull(dataObject.Environment);
            Assert.IsNotNull(field);
            Assert.AreEqual(0, field.Count);
            //---------------Execute Test ----------------------
            dataObject.PopEnvironment();
            //---------------Test Result -----------------------
            Assert.AreEqual(dataObject.Environment, mock.Object);
        }
        public void CheckOutputFormatOfDataListForViewInBrowserForOneRecordsetOutputRegion()
        {
            IDataListCompiler comp = DataListFactory.CreateDataListCompiler();
            ErrorResultTO     errors;
            Guid           dlId     = comp.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), string.Empty.ToStringBuilder(), ServiceShape.ToStringBuilder(), out errors);
            var            resource = ResourceCatalog.Instance.GetResource(_workspaceId, ServiceName);
            IDSFDataObject dataObj  = new DsfDataObject(string.Empty, dlId)
            {
                WorkspaceID = _workspaceId, DataListID = dlId, ServiceName = ServiceName, ResourceID = resource.ResourceID
            };
            EsbServicesEndpoint endPoint = new EsbServicesEndpoint();
            string result = endPoint.FetchExecutionPayload(dataObj, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), out errors);

            DeleteDataList(dlId);

            Assert.IsTrue(result.IndexOf("<outputScalar", StringComparison.Ordinal) > 0, "Output format missing required tag of <outputScalar>");
            Assert.IsTrue(result.IndexOf("<bothScalar", StringComparison.Ordinal) > 0, "Output format missing required tag of <bothScalar");
            Assert.IsTrue(result.IndexOf("<recset", StringComparison.Ordinal) > 0, "Output format missing required tag of <recset></recset>");
            Assert.IsTrue(result.IndexOf("<f2", StringComparison.Ordinal) > 0, "Output format missing required tag of <recset><f2/></recset>");
            Assert.IsTrue(result.IndexOf("<f3", StringComparison.Ordinal) > 0, "Output format missing required tag of <recset><f3/></recset>");
        }
        public void PerformExecution_Given_ItemsInQueue_ExecuteAndReqeue_WhenExecutedMultipleTimes_ShouldNotAppend_NoTimeout()
        {
            //------------Setup for test--------------------------
            var dataObj = new DsfDataObject(It.IsAny <string>(), It.IsAny <Guid>(), It.IsAny <string>());
            var dsfConsumeRabbitMQActivity = new DsfConsumeRabbitMQActivity();

            const string queueName         = "Q1";
            var          resourceCatalog   = new Mock <IResourceCatalog>();
            var          rabbitMQSource    = new Mock <RabbitMQSource>();
            var          connectionFactory = new Mock <ConnectionFactory>();
            var          connection        = new Mock <IConnection>();
            var          channel           = new Mock <IModel>();

            resourceCatalog.Setup(r => r.GetResource <RabbitMQSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(rabbitMQSource.Object);
            connectionFactory.Setup(c => c.CreateConnection()).Returns(connection.Object);
            connection.Setup(c => c.CreateModel()).Returns(channel.Object);
            channel.Setup(c => c.BasicQos(0, 1, false));
            channel.Setup(c => c.BasicConsume(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <QueueingBasicConsumer>()));
            var basicGetResult1 = new BasicGetResult(1, true, queueName, "", 1, new BasicProperties(), Encoding.Default.GetBytes("hello"));
            var basicGetResult2 = new BasicGetResult(2, true, queueName, "", 1, new BasicProperties(), Encoding.Default.GetBytes("world"));

            channel.SetupSequence(model => model.BasicGet(queueName, It.IsAny <bool>())).Returns(basicGetResult1).Returns(basicGetResult2);
            var privateObject = new PrivateObject(dsfConsumeRabbitMQActivity);

            privateObject.SetProperty("ConnectionFactory", connectionFactory.Object);
            privateObject.SetProperty("ResourceCatalog", resourceCatalog.Object);
            privateObject.SetProperty("QueueName", queueName);
            dsfConsumeRabbitMQActivity.Response = "[[msgs().message]]";
            dsfConsumeRabbitMQActivity.ReQueue  = true;
            //------------Execute Test---------------------------
            privateObject.Invoke("ExecuteTool", dataObj, 0);
            privateObject.Invoke("ExecuteTool", dataObj, 0);
            privateObject.Invoke("ExecuteTool", dataObj, 0);
            //------------Assert Results-------------------------
            IList <string> actualRecset;
            string         error;

            GetRecordSetFieldValueFromDataList(dataObj.Environment, "msgs", "message", out actualRecset, out error);
            Assert.AreEqual(2, actualRecset.Count);
        }
Ejemplo n.º 13
0
        public void DsfNativeActivity_ExecuteTool_DebugFalse_TestExecution()
        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                ServerID               = Guid.NewGuid(),
                IsDebug                = false,
                ForEachNestingLevel    = 0,
                IsServiceTestExecution = true
            };

            var act = new TestNativeActivity(false, "bob");

            var serviceTestModelTO = new ServiceTestModelTO
            {
                TestSteps = new List <IServiceTestStep>
                {
                    new ServiceTestStepTO
                    {
                        UniqueId    = Guid.Parse(act.UniqueID),
                        Type        = StepType.Assert,
                        StepOutputs = new ObservableCollection <IServiceTestOutput>
                        {
                            new ServiceTestOutputTO
                            {
                                AssertOp = "=",
                                Value    = "Bob",
                                Variable = "[[var]]"
                            }
                        }
                    }
                }
            };

            dataObject.ServiceTest = serviceTestModelTO;

            act.Execute(dataObject, 0);

            Assert.AreEqual(RunResult.TestFailed, serviceTestModelTO.Result.RunTestResult);
            Assert.IsTrue(dataObject.StopExecution);
        }
Ejemplo n.º 14
0
        public void SharepointSource_Exists_OnResourceCatalog_BlankRecordSet()
        {
            //------------Setup for test--------------------------
            const string activityName = "SharepointReadList";
            var          resourceId   = Guid.NewGuid();
            var          sharepointReadListActivity = new SharepointReadListActivity
            {
                DisplayName = activityName,
                SharepointServerResourceId = resourceId,
                ReadListItems             = new List <SharepointReadListTo>(),
                FilterCriteria            = new List <SharepointSearchTo>(),
                RequireAllCriteriaToMatch = true,
                SharepointUtils           = new SharepointUtils()
            };

            var dataObj = new DsfDataObject("", Guid.NewGuid(), "");

            var resourceCatalog = new Mock <IResourceCatalog>();

            var mockSharepointHelper = new Mock <ISharepointHelper>();

            mockSharepointHelper.Setup(helper => helper.CopyFile(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())).Returns("Success");

            var mockSharepointSource = new MockSharepointSource
            {
                MockSharepointHelper = mockSharepointHelper.Object
            };

            resourceCatalog.Setup(r => r.GetResource <SharepointSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(mockSharepointSource);

            var privateObject = new PrivateObject(sharepointReadListActivity);

            privateObject.SetProperty("ResourceCatalog", resourceCatalog.Object);

            //------------Execute Test---------------------------
            privateObject.Invoke("ExecuteTool", dataObj, 0);
            //------------Assert Result--------------------------
            GetRecordSetFieldValueFromDataList(dataObj.Environment, "Files", "Name", out IList <string> result, out string error);
            Assert.IsNotNull(result);
        }
Ejemplo n.º 15
0
        public void LargeRows_SplitOnNewLine_ShouldSplitCorrectly()
        {
            IList <DataSplitDTO> resultsCollection = new List <DataSplitDTO>();

            resultsCollection.Add(new DataSplitDTO("[[rec().data]]", "New Line", "", 1));
            var sourceString = File.ReadAllText("LargeRowsDataSplit.txt");
            var act          = new DsfDataSplitActivity {
                SourceString = sourceString, ResultsCollection = resultsCollection, SkipBlankRows = true
            };
            var dataObject = new DsfDataObject("", Guid.Empty)
            {
                IsDebug = false,
            };

            act.Execute(dataObject, 0);

            var totalCount = dataObject.Environment.GetCount("rec");
            var res        = dataObject.Environment.Eval("[[rec().data]]", 0) as CommonFunctions.WarewolfEvalResult.WarewolfAtomListresult;

            Assert.AreEqual("0827373254", res.Item.First().ToString());
            Assert.AreEqual(8300000, totalCount, CurrentDl);
        }
        public void JsonMappingCompoundTo_MaxCount_NotIsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());

            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            dataObject.Environment.Assign("[[rec(2).a]]", "60", 0);
            dataObject.Environment.Assign("[[rec(2).b]]", "600", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
            {
                SourceName      = "[[rec().a]]",
                DestinationName = "myName"
            }
                );

            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.MaxCount, 1);

            // check for list
            jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
            {
                SourceName      = "[[rec(*).a]]",
                DestinationName = "myName"
            }
                );
            Assert.IsFalse(jsonMappingCompound.IsCompound);
            Assert.AreEqual(jsonMappingCompound.MaxCount, 2);
        }
Ejemplo n.º 17
0
        public void GateActivity_Execute_GivenNoConditions_ExpectDetailedLog()
        {
            var expectedNextActivity = new Mock <IDev2Activity>();

            //---------------Set up test pack-------------------

            //------------Setup for test--------------------------
            var act = new GateActivity
            {
                Conditions = new List <ConditionExpression>(),
                NextNodes  = new List <IDev2Activity> {
                    expectedNextActivity.Object
                },
            };


            var dataObject = new DsfDataObject("", Guid.NewGuid());

            var result = act.Execute(dataObject, 0);

            Assert.AreEqual(expectedNextActivity.Object, result);
        }
Ejemplo n.º 18
0
        private string ExecuteOverrideDataFunc(ForEachInnerActivityTO innerActivity)
        {
            IDSFDataObject dataObject = new DsfDataObject(string.Empty, Guid.Empty);

            var origInnerInputMapping = innerActivity.OrigInnerInputMapping;
            var inputs = TranslateInputMappingToInputs(origInnerInputMapping);

            foreach (var serviceInput in inputs)
            {
                var isVariable = ExecutionEnvironment.IsValidVariableExpression(serviceInput.Value, out string errorMessage, 0);
                if (isVariable)
                {
                    var inputName  = _dataObject.Environment.EvalToExpression(serviceInput.Value, _update);
                    var inputValue = ExecutionEnvironment.WarewolfEvalResultToString(_dataObject.Environment.Eval(inputName, _update, false, true));
                    dataObject.Environment.AssignWithFrame(new AssignValue(inputName, inputValue), _update);
                }
                else
                {
                    dataObject.Environment.AssignWithFrame(new AssignValue("[[" + serviceInput.Name + "]]", serviceInput.Value), _update);
                }
            }
            return(dataObject.Environment.ToJson());
        }
        public void ExecutionEnvironmentUtils_GetXmlOutputFromEnvironment_WhenHasRecordset_ShouldNotError()
        {
            //------------Setup for test--------------------------
            var          dataObj  = new DsfDataObject(string.Empty, Guid.NewGuid());
            const string dataList = "<DataList>" +
                                    "<rec Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\">" +
                                    "<a Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\" />" +
                                    "</rec>" +
                                    "</DataList>";

            dataObj.Environment.Assign("[[rec().a]]", "1", 0);
            dataObj.Environment.Assign("[[rec().a]]", "2", 0);
            //------------Execute Test---------------------------
            var actual = ExecutionEnvironmentUtils.GetXmlOutputFromEnvironment(dataObj, dataList, 0);

            //------------Assert Results-------------------------
            StringAssert.Contains(actual, "<DataList>");
            StringAssert.Contains(actual, "<rec>");
            StringAssert.Contains(actual, "<a>1</a>");
            StringAssert.Contains(actual, "<a>2</a>");
            StringAssert.Contains(actual, "</rec>");
            StringAssert.Contains(actual, "</DataList>");
        }
        public void JsonMappingCompoundTo_Constructor_SetsProperties_NotIsCompound()
        {
            //------------Setup for test--------------------------
            // ReSharper disable RedundantArgumentName
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());

            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo {
                SourceName = "[[a]]", DestinationName = "a"
            }
                );

            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsFalse(jsonMappingCompound.IsCompound);
        }
Ejemplo n.º 21
0
        public void DsfNativeActivity_ExecuteTool_Errors_PerformsErrorHandling_ShouldReturnErrors()
        {
            var dataObject = new DsfDataObject("<Datalist></Datalist>", Guid.NewGuid())
            {
                ServerID               = Guid.NewGuid(),
                IsDebug                = false,
                ForEachNestingLevel    = 0,
                IsServiceTestExecution = true
            };

            var act = new TestNativeActivity(false, "bob");

            act.IsEndedOnError  = true;
            act.OnErrorVariable = "[[Error().Massage]]";
            dataObject.Environment.AddError("There is an error with special character: [[special.willNotParse)");

            _ = act.Execute(dataObject, 0);

            var errors = dataObject.Environment.Errors;

            Assert.AreEqual("There is an error with special character: [[special.willNotParse)", errors.First(), "Warewolf error cannot have special characters");
            Assert.AreEqual("parse error: { Error().Massage }", errors.Last());
        }
        public void CheckOutputFormatOfDataListForViewInBrowserForAllInputRegions()
        {
            IDataListCompiler comp = DataListFactory.CreateDataListCompiler();
            ErrorResultTO     errors;
            Guid dlId = comp.ConvertTo(DataListFormat.CreateFormat(GlobalConstants._XML), string.Empty, ServiceShape.ToStringBuilder(), out errors);

            IDSFDataObject dataObj = new DsfDataObject(string.Empty, dlId)
            {
                WorkspaceID = _workspaceId, DataListID = dlId, ServiceName = ServiceName
            };
            EsbServicesEndpoint endPoint = new EsbServicesEndpoint();
            string result = endPoint.FetchExecutionPayload(dataObj, DataListFormat.CreateFormat(GlobalConstants._XML_Without_SystemTags), out errors);

            DeleteDataList(dlId);

            Assert.IsTrue(result.IndexOf("<inputScalar", StringComparison.Ordinal) < 0, "Output format contains additional tag, <inputScalar>");
            Assert.IsTrue(result.IndexOf("<noneScalar", StringComparison.Ordinal) < 0, "Output format contains additional tag, <noneScalar>");
            Assert.IsTrue(result.IndexOf("<f1", StringComparison.Ordinal) < 0, "Output format contains additional tag, <recset><f1/></recset>");
            Assert.IsTrue(result.IndexOf("<f4", StringComparison.Ordinal) < 0, "Output format contains additional tag, <recset><f4/></recset>");
            Assert.IsTrue(result.IndexOf("<newrecset", StringComparison.Ordinal) < 0, "Output format contains additional tag, <newrecset></newrecset>");
            Assert.IsTrue(result.IndexOf("<field1", StringComparison.Ordinal) < 0, "Output format contains additional tag, <newrecset><f1/></newrecset>");
            Assert.IsTrue(result.IndexOf("<field2", StringComparison.Ordinal) < 0, "Output format contains additional tag, <newrecset><f1/></newrecset>");
        }
Ejemplo n.º 23
0
        public void DsfNativeActivity_DispatchDebugState_Before_SetsStartTimeCorrectly()
        {
            var             parentInstanceID = Guid.NewGuid();
            const StateType StateType        = StateType.Before;

            var dataObj = new DsfDataObject(string.Empty, GlobalConstants.NullDataListID)
            {
                IsDebug = true,
                IsOnDemandSimulation = false,
                EnvironmentID        = Guid.NewGuid(),
                WorkspaceID          = Guid.NewGuid(),
                ServerID             = Guid.NewGuid(),
                ResourceID           = Guid.NewGuid(),
                OriginalInstanceID   = Guid.NewGuid(),
                ParentInstanceID     = parentInstanceID.ToString()
            };

            var activity = new TestActivity
            {
                IsSimulationEnabled = false,
                SimulationMode      = SimulationMode.Never,
                ScenarioID          = Guid.NewGuid().ToString(),
                IsWorkflow          = true,
            };
            var cat = new Mock <IResourceCatalog>();
            var res = new Mock <IResource>();

            res.Setup(a => a.ResourceName).Returns("bob");
            cat.Setup(a => a.GetResource(Guid.Empty, It.IsAny <Guid>())).Returns(res.Object);
            activity.ResourceCatalog = cat.Object;
            var actual = activity.TestDispatchDebugState(dataObj, StateType);

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual.StartTime);
            Assert.AreNotEqual(DateTime.MinValue, actual.StartTime);
            Assert.AreEqual(DateTime.MinValue, actual.EndTime);
        }
        public void ExecutionEnvironmentUtils_GetXmlOutputFromEnvironment_WhenDataList_ShouldOnlyHaveVariablesMarkedAsOutputInString()
        {
            //------------Setup for test--------------------------
            var          dataObj  = new DsfDataObject(string.Empty, Guid.NewGuid());
            const string dataList = "<DataList>" +
                                    "<Name Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Input\"/>" +
                                    "<Surname Description=\"\" IsEditable=\"True\" ColumnIODirection=\"None\"/>" +
                                    "<FullName Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\"/>" +
                                    "<rec Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\">" +
                                    "<a Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Output\" />" +
                                    "<b Description=\"\" IsEditable=\"True\" ColumnIODirection=\"None\" />" +
                                    "<c Description=\"\" IsEditable=\"True\" ColumnIODirection=\"Input\" />" +
                                    "</rec>" +
                                    "</DataList>";

            dataObj.Environment.Assign("[[rec().a]]", "1", 0);
            dataObj.Environment.Assign("[[rec().b]]", "2", 0);
            dataObj.Environment.Assign("[[rec().c]]", "3", 0);
            dataObj.Environment.Assign("[[Name]]", "Bob", 0);
            dataObj.Environment.Assign("[[Surname]]", "Mary", 0);
            dataObj.Environment.Assign("[[FullName]]", "Bob Mary", 0);
            //------------Execute Test---------------------------
            var actual = ExecutionEnvironmentUtils.GetXmlOutputFromEnvironment(dataObj, dataList, 0);

            //------------Assert Results-------------------------
            StringAssert.Contains(actual, "<DataList>");
            StringAssert.Contains(actual, "<rec>");
            StringAssert.Contains(actual, "<a>1</a>");
            StringAssert.Contains(actual, "<a></a>");
            StringAssert.Contains(actual, "</rec>");
            StringAssert.Contains(actual, "</DataList>");
            StringAssert.Contains(actual, "<FullName>Bob Mary</FullName>");
            Assert.IsFalse(actual.Contains("<Name>Bob</Name>"));
            Assert.IsFalse(actual.Contains("<Surname>Mary</Surname>"));
            Assert.IsFalse(actual.Contains("<b>2</b>"));
            Assert.IsFalse(actual.Contains("<c>3</c>"));
        }
Ejemplo n.º 25
0
        protected static void BindRequestVariablesToDataObject(WebRequestTO request, ref DsfDataObject dataObject)
        {
            if (dataObject != null && request != null)
            {
                if (!string.IsNullOrEmpty(request.Bookmark))
                {
                    dataObject.CurrentBookmarkName = request.Bookmark;
                }

                if (!string.IsNullOrEmpty(request.InstanceID))
                {
                    Guid tmpId;
                    if (Guid.TryParse(request.InstanceID, out tmpId))
                    {
                        dataObject.WorkflowInstanceId = tmpId;
                    }
                }

                if (!string.IsNullOrEmpty(request.ServiceName) && string.IsNullOrEmpty(dataObject.ServiceName))
                {
                    dataObject.ServiceName = request.ServiceName;
                }
            }
        }
        public void JsonMappingCompoundTo_EvalResultIndexed_IsCompound()
        {
            //------------Setup for test--------------------------
            var dataObject = new DsfDataObject(xmldata: string.Empty, dataListId: Guid.NewGuid());

            dataObject.Environment.Assign("[[a]]", "10", 0);
            dataObject.Environment.Assign("[[b]]", "20", 0);
            dataObject.Environment.Assign("[[rec(1).a]]", "50", 0);
            dataObject.Environment.Assign("[[rec(1).b]]", "500", 0);
            //------------Execute Test---------------------------

            var jsonMappingCompound = new JsonMappingCompoundTo(
                env: dataObject.Environment,
                compound: new JsonMappingTo
            {
                SourceName      = "[[a]],[[b]]",
                DestinationName = "myName"
            }
                );

            //------------Assert Results-------------------------
            Assert.IsNotNull(jsonMappingCompound);
            Assert.IsTrue(jsonMappingCompound.IsCompound);
        }
Ejemplo n.º 27
0
        public void SharepointCopyFileActivity_ValidateRequest_ServerInputPathFrom_IsEmpty_ExpectAreEqual_Success()
        {
            //------------Setup for test--------------------------
            const string activityName = "SharepointCopyFile";

            var resourceCatalog      = new Mock <IResourceCatalog>();
            var mockSharepointSource = new Mock <SharepointSource>();

            var resourceId = Guid.NewGuid();
            var sharepointCopyFileActivity = new SharepointCopyFileActivity
            {
                DisplayName = activityName,
                SharepointServerResourceId = resourceId,
                Result            = "[[Files(*).Name]]",
                ServerInputPathTo = "Hello World.bite",
                Overwrite         = true
            };

            var privateObject = new Warewolf.Testing.PrivateObject(sharepointCopyFileActivity);
            var dataObj       = new DsfDataObject("", Guid.NewGuid(), "");

            resourceCatalog.Setup(r => r.GetResource <SharepointSource>(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(mockSharepointSource.Object);

            sharepointCopyFileActivity.ResourceCatalog  = resourceCatalog.Object;
            sharepointCopyFileActivity.SharepointSource = mockSharepointSource.Object;
            try
            {
                //------------Execute Test---------------------------
                privateObject.Invoke("ValidateRequest");
            }
            catch (TargetInvocationException e)
            {
                //------------Assert Result--------------------------
                Assert.AreEqual("Server input path FROM is not set", e.InnerException?.Message, "Expected exception was not thrown");
            }
        }
Ejemplo n.º 28
0
        public void DataObject_Ctor_WhenXmlStringContainsAllIncludingDataMergePropertiesSet_ExpectParseAndSet()
        {
            //------------Setup for test--------------------------
            var debugID       = Guid.NewGuid();
            var envID         = Guid.NewGuid();
            var exeID         = Guid.NewGuid();
            var bookmarkID    = Guid.NewGuid();
            var parentID      = Guid.NewGuid();
            var instID        = Guid.NewGuid();
            var mergeIDOut    = Guid.NewGuid();
            var mergeIDIn     = Guid.NewGuid();
            var versionNumber = "3";

            var xmlStr = "<Payload>" +
                         "<IsDebug>true</IsDebug>" +
                         "<DebugSessionID>" + debugID + "</DebugSessionID>" +
                         "<EnvironmentID>" + envID + "</EnvironmentID>" +
                         "<VersionNumber>" + versionNumber + "</VersionNumber>" +
                         "<IsOnDemandSimulation>true</IsOnDemandSimulation>" +
                         "<ParentServiceName>TestParentService</ParentServiceName>" +
                         "<ExecutionCallbackID>" + exeID + "</ExecutionCallbackID>" +
                         "<BookmarkExecutionCallbackID>" + bookmarkID + "</BookmarkExecutionCallbackID>" +
                         "<ParentInstanceID>" + parentID + "</ParentInstanceID>" +
                         "<NumberOfSteps>5</NumberOfSteps>" +
                         "<CurrentBookmarkName>MyBookmark</CurrentBookmarkName>" +
                         "<WorkflowInstanceId>" + instID + "</WorkflowInstanceId>" +
                         "<IsDataListScoped>true</IsDataListScoped>" +
                         "<Service>MyTestService</Service>" +
                         "<DatalistOutMergeID>" + mergeIDOut + "</DatalistOutMergeID>" +
                         "<DatalistOutMergeType>Union</DatalistOutMergeType>" +
                         "<DatalistOutMergeDepth>Data</DatalistOutMergeDepth>" +
                         "<DatalistOutMergeFrequency>Never</DatalistOutMergeFrequency>" +
                         "<DatalistInMergeID>" + mergeIDIn + "</DatalistInMergeID>" +
                         "<DatalistInMergeType>Union</DatalistInMergeType>" +
                         "<DatalistInMergeDepth>Data</DatalistInMergeDepth>" +
                         "</Payload>";


            //------------Execute Test---------------------------
            var dataObjct = new DsfDataObject(xmlStr, Guid.NewGuid(), "<x>1</x>");

            //------------Assert Results-------------------------
            Assert.IsTrue(dataObjct.IsDebug);
            StringAssert.Contains(dataObjct.DebugSessionID.ToString(), debugID.ToString());
            StringAssert.Contains(dataObjct.EnvironmentID.ToString(), envID.ToString());
            StringAssert.Contains(dataObjct.VersionNumber.ToString(), versionNumber);
            Assert.IsTrue(dataObjct.IsOnDemandSimulation);
            StringAssert.Contains(dataObjct.ParentServiceName, "TestParentService");
            StringAssert.Contains(dataObjct.ExecutionCallbackID.ToString(), exeID.ToString());
            StringAssert.Contains(dataObjct.BookmarkExecutionCallbackID.ToString(), bookmarkID.ToString());
            StringAssert.Contains(dataObjct.ParentInstanceID, parentID.ToString());
            Assert.AreEqual(5, dataObjct.NumberOfSteps, "Wrong number of steps");
            StringAssert.Contains(dataObjct.CurrentBookmarkName, "MyBookmark");
            StringAssert.Contains(dataObjct.WorkflowInstanceId.ToString(), instID.ToString());
            Assert.IsTrue(dataObjct.IsDataListScoped);
            StringAssert.Contains(dataObjct.ServiceName, "MyTestService");
            StringAssert.Contains(dataObjct.RawPayload.ToString(), xmlStr);

            // Data Merge Checks
            StringAssert.Contains(dataObjct.DatalistOutMergeID.ToString(), mergeIDOut.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeType.ToString(), enDataListMergeTypes.Union.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeDepth.ToString(), Common.Interfaces.DataList.Contract.enTranslationDepth.Data.ToString());
            StringAssert.Contains(dataObjct.DatalistOutMergeFrequency.ToString(), DataListMergeFrequency.OnCompletion.ToString());

            StringAssert.Contains(dataObjct.DatalistInMergeID.ToString(), mergeIDIn.ToString());
            StringAssert.Contains(dataObjct.DatalistInMergeType.ToString(), enDataListMergeTypes.Union.ToString());
            StringAssert.Contains(dataObjct.DatalistInMergeDepth.ToString(), Common.Interfaces.DataList.Contract.enTranslationDepth.Data.ToString());
        }
Ejemplo n.º 29
0
        public void DsfDataObject_Clone_NormalClone_FullDuplicationForProperties()
        {
            var executingUser = new Mock <IPrincipal>().Object;
            //------------Setup for test--------------------------
            var            wfInstanceID = Guid.NewGuid();
            IDSFDataObject dataObject   = new DsfDataObject(string.Empty, Guid.NewGuid(), "<x>1</x>");

            dataObject.BookmarkExecutionCallbackID = Guid.NewGuid();
            dataObject.CurrentBookmarkName         = "def";
            dataObject.DataList                               = new StringBuilder("<x/>");
            dataObject.DataListID                             = Guid.NewGuid();
            dataObject.DatalistInMergeDepth                   = enTranslationDepth.Data;
            dataObject.DatalistInMergeID                      = Guid.NewGuid();
            dataObject.DatalistInMergeType                    = enDataListMergeTypes.Union;
            dataObject.DatalistOutMergeDepth                  = enTranslationDepth.Data;
            dataObject.DatalistOutMergeFrequency              = DataListMergeFrequency.Always;
            dataObject.DatalistOutMergeID                     = Guid.NewGuid();
            dataObject.DatalistOutMergeType                   = enDataListMergeTypes.Union;
            dataObject.DebugSessionID                         = Guid.NewGuid();
            dataObject.EnvironmentID                          = Guid.NewGuid();
            dataObject.VersionNumber                          = 1;
            dataObject.ExecutionCallbackID                    = Guid.NewGuid();
            dataObject.ExecutionOrigin                        = ExecutionOrigin.Debug;
            dataObject.ExecutingUser                          = executingUser;
            dataObject.ExecutionOriginDescription             = "xxx";
            dataObject.ForceDeleteAtNextNativeActivityCleanup = true;
            dataObject.IsDataListScoped                       = false;
            dataObject.IsDebug                  = true;
            dataObject.IsFromWebServer          = true;
            dataObject.IsOnDemandSimulation     = true;
            dataObject.NumberOfSteps            = 2;
            dataObject.OriginalInstanceID       = Guid.NewGuid();
            dataObject.ParentInstanceID         = "1211";
            dataObject.ParentServiceName        = "xxx";
            dataObject.ParentThreadID           = 2;
            dataObject.ParentWorkflowInstanceId = "1233";
            dataObject.RawPayload               = new StringBuilder("<raw>a</raw>");
            dataObject.RemoteDebugItems         = new List <IDebugState>();
            dataObject.RemoteInvoke             = false;
            dataObject.RemoteInvokeResultShape  = new StringBuilder("<x/>");
            dataObject.RemoteInvokerID          = "999";
            dataObject.RemoteServiceType        = "NA";
            dataObject.ResourceID               = Guid.NewGuid();
            dataObject.ReturnType               = EmitionTypes.XML;
            dataObject.ServerID                 = Guid.NewGuid();
            dataObject.ServiceName              = "xxx";
            dataObject.WorkflowInstanceId       = wfInstanceID;
            dataObject.WorkflowResumeable       = false;
            dataObject.ParentID                 = Guid.NewGuid();
            dataObject.WorkspaceID              = Guid.NewGuid();
            dataObject.ClientID                 = Guid.NewGuid();
            dataObject.RunWorkflowAsync         = true;
            dataObject.IsDebugNested            = true;
            dataObject.ForEachNestingLevel      = 3;
            dataObject.StopExecution            = false;
            dataObject.IsServiceTestExecution   = true;
            dataObject.TestName                 = "Test 1";
            dataObject.IsDebugFromWeb           = true;
            dataObject.SourceResourceID         = Guid.NewGuid();
            dataObject.IsSubExecution           = true;
            dataObject.ServiceTest              = new ServiceTestModelTO {
                TestName = "Test Mock"
            };
            dataObject.StateNotifier = new Mock <IStateNotifier>().Object;
            dataObject.Settings      = new Dev2WorkflowSettingsTO {
                KeepLogsForDays = 999
            };
            var threadsToDispose = new Dictionary <int, List <Guid> >();
            var guidList         = new List <Guid> {
                Guid.NewGuid()
            };

            threadsToDispose.Add(3, guidList);
            dataObject.ThreadsToDispose = threadsToDispose;
            dataObject.AuthCache        = new ConcurrentDictionary <(IPrincipal, Dev2.Common.Interfaces.Enums.AuthorizationContext, string), bool>();

            //------------Execute Test---------------------------
            var clonedObject = dataObject.Clone();

            //------------Assert Results-------------------------

            // check counts, then check values
            var properties = typeof(IDSFDataObject).GetProperties();

            Assert.AreEqual(72, properties.Length);

            // now check each value to ensure it transfered
            Assert.AreEqual(dataObject.BookmarkExecutionCallbackID, clonedObject.BookmarkExecutionCallbackID);
            Assert.AreEqual(dataObject.CurrentBookmarkName, clonedObject.CurrentBookmarkName);
            Assert.AreEqual(dataObject.DataList, clonedObject.DataList);
            Assert.AreEqual(dataObject.DataListID, clonedObject.DataListID);
            Assert.AreEqual(dataObject.DatalistInMergeDepth, clonedObject.DatalistInMergeDepth);
            Assert.AreEqual(dataObject.DatalistInMergeID, clonedObject.DatalistInMergeID);
            Assert.AreEqual(dataObject.DatalistInMergeType, clonedObject.DatalistInMergeType);
            Assert.AreEqual(dataObject.DatalistOutMergeDepth, clonedObject.DatalistOutMergeDepth);
            Assert.AreEqual(dataObject.DatalistOutMergeFrequency, clonedObject.DatalistOutMergeFrequency);
            Assert.AreEqual(dataObject.DatalistOutMergeID, clonedObject.DatalistOutMergeID);
            Assert.AreEqual(dataObject.DatalistOutMergeType, clonedObject.DatalistOutMergeType);
            Assert.AreEqual(dataObject.DebugSessionID, clonedObject.DebugSessionID);
            Assert.AreEqual(dataObject.EnvironmentID, clonedObject.EnvironmentID);
            Assert.AreEqual(dataObject.VersionNumber, clonedObject.VersionNumber);
            Assert.AreEqual(dataObject.ExecutingUser, clonedObject.ExecutingUser);
            Assert.AreEqual(dataObject.ExecutionCallbackID, clonedObject.ExecutionCallbackID);
            Assert.AreEqual(dataObject.ExecutionOrigin, clonedObject.ExecutionOrigin);
            Assert.AreEqual(dataObject.ExecutionOriginDescription, clonedObject.ExecutionOriginDescription);
            Assert.AreEqual(dataObject.ForceDeleteAtNextNativeActivityCleanup, clonedObject.ForceDeleteAtNextNativeActivityCleanup);
            Assert.AreEqual(dataObject.IsDataListScoped, clonedObject.IsDataListScoped);
            Assert.AreEqual(dataObject.IsDebug, clonedObject.IsDebug);
            Assert.AreEqual(dataObject.IsFromWebServer, clonedObject.IsFromWebServer);
            Assert.AreEqual(dataObject.IsOnDemandSimulation, clonedObject.IsOnDemandSimulation);
            Assert.AreEqual(dataObject.IsRemoteInvoke, clonedObject.IsRemoteInvoke);
            Assert.AreEqual(dataObject.IsRemoteInvokeOverridden, clonedObject.IsRemoteInvokeOverridden);
            Assert.AreEqual(dataObject.NumberOfSteps, clonedObject.NumberOfSteps);
            Assert.AreEqual(dataObject.OriginalInstanceID, clonedObject.OriginalInstanceID);
            Assert.AreEqual(dataObject.ParentInstanceID, clonedObject.ParentInstanceID);
            Assert.AreEqual(dataObject.ParentServiceName, clonedObject.ParentServiceName);
            Assert.AreEqual(dataObject.ParentThreadID, clonedObject.ParentThreadID);
            Assert.AreEqual(dataObject.ParentWorkflowInstanceId, clonedObject.ParentWorkflowInstanceId);
            Assert.AreEqual(dataObject.RawPayload, clonedObject.RawPayload);
            Assert.AreEqual(dataObject.RemoteDebugItems, clonedObject.RemoteDebugItems);
            Assert.AreEqual(dataObject.RemoteInvoke, clonedObject.RemoteInvoke);
            Assert.AreEqual(dataObject.RemoteNonDebugInvoke, clonedObject.RemoteNonDebugInvoke);
            Assert.AreEqual(dataObject.RemoteInvokeResultShape, clonedObject.RemoteInvokeResultShape);
            Assert.AreEqual(dataObject.RemoteInvokerID, clonedObject.RemoteInvokerID);
            Assert.AreEqual(dataObject.RemoteServiceType, clonedObject.RemoteServiceType);
            Assert.AreEqual(dataObject.ResourceID, clonedObject.ResourceID);
            Assert.AreEqual(dataObject.ReturnType, clonedObject.ReturnType);
            Assert.AreEqual(dataObject.ServerID, clonedObject.ServerID);
            Assert.AreEqual(dataObject.ClientID, clonedObject.ClientID);
            Assert.AreEqual(dataObject.ServiceName, clonedObject.ServiceName);
            Assert.AreEqual(dataObject.WorkflowInstanceId, clonedObject.WorkflowInstanceId);
            Assert.AreEqual(dataObject.WorkflowResumeable, clonedObject.WorkflowResumeable);
            Assert.AreEqual(dataObject.WorkspaceID, clonedObject.WorkspaceID);
            Assert.AreEqual(dataObject.ThreadsToDispose, clonedObject.ThreadsToDispose);
            Assert.AreEqual(dataObject.ParentID, clonedObject.ParentID);
            Assert.AreEqual(dataObject.RunWorkflowAsync, clonedObject.RunWorkflowAsync);
            Assert.AreEqual(dataObject.IsDebugNested, clonedObject.IsDebugNested);
            Assert.AreEqual(dataObject.ForEachNestingLevel, clonedObject.ForEachNestingLevel);
            Assert.AreEqual(dataObject.StopExecution, clonedObject.StopExecution);
            Assert.AreEqual(dataObject.SourceResourceID, clonedObject.SourceResourceID);
            Assert.AreEqual(dataObject.TestName, clonedObject.TestName);
            Assert.AreEqual(dataObject.IsServiceTestExecution, clonedObject.IsServiceTestExecution);
            Assert.AreEqual(dataObject.IsDebugFromWeb, clonedObject.IsDebugFromWeb);
            Assert.AreNotEqual(dataObject.ServiceTest, clonedObject.ServiceTest);
            Assert.AreEqual(dataObject.ServiceTest.TestName, clonedObject.ServiceTest.TestName);
            Assert.AreEqual(dataObject.IsSubExecution, clonedObject.IsSubExecution);
            Assert.AreEqual(dataObject.WebUrl, clonedObject.WebUrl);
            Assert.AreEqual(dataObject.QueryString, clonedObject.QueryString);
            Assert.AreEqual(dataObject.ExecutingUser, clonedObject.ExecutingUser);
            Assert.AreEqual(dataObject.StateNotifier, clonedObject.StateNotifier);
            Assert.AreNotEqual(dataObject.Settings, clonedObject.Settings);
            Assert.AreEqual(dataObject.Settings.KeepLogsForDays, clonedObject.Settings.KeepLogsForDays);
            Assert.AreNotEqual(dataObject.AuthCache, clonedObject.AuthCache);
            Assert.AreEqual(dataObject.ExecutionException, clonedObject.ExecutionException);
        }
Ejemplo n.º 30
0
        public void GateActivity_Execute_GivenPassingConditionsOnFirstGateAndFailingSecondGate_ExpectDetailedLog()
        {
            var firstGateId  = Guid.NewGuid();
            var secondGateId = Guid.NewGuid();

            var failingCondition = new ConditionExpression
            {
                Left = "[[somebob]]",
                Cond = new ConditionMatch {
                    MatchType = enDecisionType.IsEqual, Right = "notbob"
                }
            };
            var failingConditions = new List <ConditionExpression>();

            failingConditions.Add(failingCondition);

            var thirdNode  = new Mock <IDev2Activity>().Object;
            var secondGate = new GateActivity
            {
                UniqueID          = secondGateId.ToString(),
                RetryEntryPointId = firstGateId,
                Conditions        = failingConditions,
                NextNodes         = new List <IDev2Activity> {
                    thirdNode
                },
            };

            //---------------Set up test pack-------------------
            var passingCondition = new ConditionExpression
            {
                Left = "[[a]]",
                Cond = new ConditionMatch {
                    MatchType = enDecisionType.IsEqual, Right = "bob"
                }
            };
            var passingConditions = new List <ConditionExpression>();

            passingConditions.Add(passingCondition);

            //------------Setup for test--------------------------
            var firstGate = new GateActivity
            {
                UniqueID   = firstGateId.ToString(),
                Conditions = passingConditions,
                NextNodes  = new List <IDev2Activity> {
                    secondGate
                },
                GateOptions = new GateOptions()
                {
                    GateOpts = new Continue()
                }
            };

            var mockStateNotifier = new Mock <IStateNotifier>();

            mockStateNotifier.Setup(stateNotifier => stateNotifier.LogActivityExecuteState(It.IsAny <IDev2Activity>()));

            firstGate.SetStateNotifier(mockStateNotifier.Object);

            var dataObject = new DsfDataObject("", Guid.NewGuid());

            dataObject.Environment.Assign("[[a]]", "bob", 0);

            var result = firstGate.Execute(dataObject, 0);

            dataObject.Environment.Assign("[[a]]", "ralph", 0);

            Assert.AreEqual("ralph", dataObject.Environment.EvalAsListOfStrings("[[a]]", 0)[0]);
            Assert.AreEqual(secondGate, result);

            result = result.Execute(dataObject, 0);

            Assert.AreEqual(firstGate, result);

            result = result.Execute(dataObject, 0);

            Assert.AreEqual("bob", dataObject.Environment.EvalAsListOfStrings("[[a]]", 0)[0]);
            Assert.AreEqual(secondGate, result);

            dataObject.Environment.Assign("[[somebob]]", "notbob", 0);

            result = result.Execute(dataObject, 0);

            Assert.AreEqual(thirdNode, result);

            mockStateNotifier.Verify(o => o.LogActivityExecuteState(It.IsAny <IDev2Activity>()), Times.Exactly(2));
        }