public void DsfActivity_BeforeExecutionStart_ResourceIDAutorised_Executes()
        {
            //------------Setup for test--------------------------
            var         resourceID = Guid.NewGuid();
            DsfActivity act        = new DsfActivity {
                InputMapping = ActivityStrings.DsfActivityInputMapping, OutputMapping = ActivityStrings.DsfActivityOutputMapping, ResourceID = new InArgument <Guid>(resourceID)
            };
            var mockAutorizationService = new Mock <IAuthorizationService>();

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

            PrivateObject p = new PrivateObject(act);

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

            List <DebugItem> inRes;
            List <DebugItem> outRes;

            //------------Execute Test---------------------------
            CheckPathOperationActivityDebugInputOutput(act, @"<ADL><scalar></scalar><Numeric><num></num></Numeric><CompanyName></CompanyName><Customer><FirstName></FirstName></Customer></ADL>",
                                                       "<ADL><scalar>scalarData</scalar><Numeric><num>1</num></Numeric><Numeric><num>2</num></Numeric><Numeric><num>3</num></Numeric><Numeric><num>4</num></Numeric><CompanyName>Dev2</CompanyName><Customer><FirstName>Wallis</FirstName></Customer></ADL>", out inRes, out outRes, new Mock <IPrincipal>().Object);

            // remove test datalist ;)
            //------------Assert Results-------------------------
            Assert.AreEqual(5, inRes.Count);
        }
        public void WorkerServicePropertyInterigator_SetActivityProperties_WhenNotNullXML_ExpectPropertiesSet()
        {
            //------------Setup for test--------------------------
            IEventAggregator                 evtAg = new EventAggregator();
            Mock <IEnvironmentModel>         env   = new Mock <IEnvironmentModel>();
            Mock <IStudioResourceRepository> exp   = new Mock <IStudioResourceRepository>();

            env.Setup(e => e.Name).Returns("My Env");
            var resource = new ResourceModel(env.Object, evtAg)
            {
                WorkflowXaml = new StringBuilder("<Action SourceName=\"TheSource\" Type=\"TheType\" SourceMethod=\"SourceMethod\"></Action>")
            };

            resource.ServerResourceType = "TheType";
            var activity = new DsfActivity("FriendlyName", String.Empty, "ServiceName", string.Empty, string.Empty, string.Empty);

            //------------Execute Test---------------------------
            WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity, null);

            //------------Assert Results-------------------------
            Assert.IsFalse(activity.IsWorkflow);
            Assert.AreEqual("TheType", ((Literal <string>)(activity.Type.Expression)).Value);
            Assert.AreEqual("TheSource", activity.FriendlySourceName.Expression.ToString());
            Assert.AreEqual("SourceMethod", activity.ActionName.Expression.ToString());
        }
Exemplo n.º 3
0
        public void DsfActivity_GetDebugInputs_WhenListInput_DebugInputExists()
        {
            //------------Setup for test--------------------------
            var environmentID = Guid.Empty;
            var env           = new ExecutionEnvironment();
            var dataObject    = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentID,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            env.Assign("[[list().Name]]", "bob", 0);
            //------------Execute Test---------------------------
            var act = new DsfActivity
            {
                Inputs = new List <IServiceInput>
                {
                    new ServiceInput("Input1", "[[list(*).Name]]")
                }
            };
            var inputs = act.GetDebugInputs(env, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, inputs.Count);
            Assert.AreEqual("bob", inputs[0].ResultsList[0].Value);
        }
Exemplo n.º 4
0
        public void DsfActivity_GetDebugInputs_ServiceInputIsAtomListResult()
        {
            //------------Setup for test--------------------------
            var inputs = new List <IServiceInput>();
            var input  = new Mock <IServiceInput>();

            input.SetupGet(o => o.Value).Returns("[[theList(*).Name]]");
            inputs.Add(input.Object);
            var act = new DsfActivity
            {
                InputMapping  = ActivityStrings.DsfActivityInputMapping,
                Inputs        = inputs,
                OutputMapping = ActivityStrings.DsfActivityOutputMapping,
                ResourceID    = null,
                IsObject      = true,
                ObjectName    = "Obj",
                ObjectResult  = "{Name:BOb}"
            };

            var env = new ExecutionEnvironment();

            env.AssignStrict("[[theList().Name]]", "Albert", 0);
            env.AssignStrict("[[theList().Name]]", "Bob", 0);
            //------------Execute Test---------------------------
            var outputs = act.GetDebugInputs(env, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, outputs.Count);
            Assert.AreEqual("Albert", outputs[0].ResultsList[0].Value);
            Assert.AreEqual(false, outputs[0].ResultsList[0].HasError);
            Assert.AreEqual("Bob", outputs[0].ResultsList[1].Value);
            Assert.AreEqual(false, outputs[0].ResultsList[1].HasError);
        }
Exemplo n.º 5
0
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity)
        {
            if (resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {
                var startIdx = resource.WorkflowXaml.IndexOf("<HelpLink>", 0, true);

                if (startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf("</HelpLink>", startIdx, true);

                    if (endIdx > 0)
                    {
                        startIdx += 10;
                        var len = endIdx - startIdx;

                        activity.HelpLink = resource.WorkflowXaml.Substring(startIdx, len);
                    }
                }
            }

            if (resource.Environment != null)
            {
                activity.FriendlySourceName = resource.Environment.Name;
            }
            activity.IsWorkflow = true;
            activity.Type       = "Workflow";
        }
Exemplo n.º 6
0
        public void DsfActivity_BeforeExecutionStart_ResourceIDNotAutorised_ThrowsException()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();

            DsfActivity act = new DsfActivity {
                InputMapping = ActivityStrings.DsfActivityInputMapping, OutputMapping = ActivityStrings.DsfActivityOutputMapping, ResourceID = new InArgument <Guid>(resourceID), ServiceName = resourceID.ToString()
            };
            var mockAutorizationService = new Mock <IAuthorizationService>();

            mockAutorizationService.Setup(service => service.IsAuthorized(It.IsAny <IPrincipal>(), AuthorizationContext.Execute, resourceID.ToString())).Returns(false);
            act.AuthorizationService = mockAutorizationService.Object;
            var mockPrincipal = new Mock <IPrincipal>();
            var mockIdentity  = new Mock <IIdentity>();

            mockIdentity.Setup(identity => identity.Name).Returns("SomeUser");
            mockPrincipal.Setup(principal => principal.Identity).Returns(mockIdentity.Object);
            List <DebugItem> inRes;
            List <DebugItem> outRes;
            //------------Execute Test---------------------------
            var result = CheckPathOperationActivityDebugInputOutput(act, @"<ADL><scalar></scalar><Numeric><num></num></Numeric><CompanyName></CompanyName><Customer><FirstName></FirstName></Customer></ADL>",
                                                                    "<ADL><scalar>scalarData</scalar><Numeric><num>1</num></Numeric><Numeric><num>2</num></Numeric><Numeric><num>3</num></Numeric><Numeric><num>4</num></Numeric><CompanyName>Dev2</CompanyName><Customer><FirstName>Wallis</FirstName></Customer></ADL>", out inRes, out outRes, mockPrincipal.Object);

            // remove test datalist ;)
            var compiler = DataListFactory.CreateDataListCompiler();
            var errors   = compiler.FetchErrors(result.DataListID);

            DataListRemoval(result.DataListID);
            //--------------Assert result----------------------------
            StringAssert.Contains(errors, string.Format("User: SomeUser does not have Execute Permission to resource {0}.", resourceID));
        }
Exemplo n.º 7
0
        public void Equals_Given_SameInputsDifferentIndexes_ActivityTools_AreNotEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var inputs   = new List <Common.Interfaces.DB.IServiceInput>
            {
                new ServiceInput("Input2", "[[InputValue2]]"),
                new ServiceInput("Input1", "[[InputValue1]]")
            };
            var inputs2 = new List <Common.Interfaces.DB.IServiceInput>
            {
                new ServiceInput("Input1", "[[InputValue1]]"),
                new ServiceInput("Input2", "[[InputValue2]]")
            };
            var activity = new DsfActivity {
                UniqueID = uniqueId, Inputs = inputs
            };
            var activity1 = new DsfActivity {
                UniqueID = uniqueId, Inputs = inputs2
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity);
            //---------------Execute Test ----------------------
            var @equals = activity.Equals(activity1);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
        public static DsfActivity CreateDsfActivity(IContextualResourceModel resource, DsfActivity activity,
                                                    bool ifNullCreateNew, IEnvironmentRepository environmentRepository, bool isDesignerLocalhost)
        {
            var activityToUpdate = activity;

            if (activityToUpdate == null)
            {
                if (ifNullCreateNew)
                {
                    activityToUpdate = new DsfActivity();
                }
                else
                {
                    return(null);
                }
            }

            if (resource != null)
            {
                var activeEnvironment = environmentRepository.ActiveEnvironment;
                activityToUpdate.ResourceID = resource.ID;
                SetCorrectEnvironmentId(resource, activityToUpdate, isDesignerLocalhost, activeEnvironment);
                activityToUpdate = SetActivityProperties(resource, activityToUpdate);
            }

            activityToUpdate.ExplicitDataList = null;
            return(activityToUpdate);
        }
        public void DsfActivityFactory_UnitTest_ResourceAndEnvironmentIDAssigned_Done()
        {
            var expectedResourceID = Guid.NewGuid();
            var expectedEnvironmentID = Guid.NewGuid();

            var activity = new DsfActivity();

            var environment = new Mock<IEnvironmentModel>();
            environment.Setup(e => e.ID).Returns(expectedEnvironmentID);

            var model = new Mock<IContextualResourceModel>();
            model.Setup(m => m.ResourceType).Returns(ResourceType.Service);
            model.Setup(m => m.ID).Returns(expectedResourceID);
            model.Setup(m => m.Environment).Returns(environment.Object);
            model.Setup(m => m.WorkflowXaml).Returns(new StringBuilder("<root/>"));
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty);

            DsfActivityFactory.CreateDsfActivity(model.Object, activity, false, environmentRepository,false);

            var actualResourceID = Guid.Parse(activity.ResourceID.Expression.ToString());
            var actualEnvironmentID = Guid.Parse(activity.EnvironmentID.Expression.ToString());

            Assert.AreEqual(expectedResourceID, actualResourceID, "DsfActivityFactory did not assign the resource ID.");
            Assert.AreEqual(expectedEnvironmentID, actualEnvironmentID, "DsfActivityFactory did not assign the environment ID.");
        }
Exemplo n.º 10
0
        public void ConflictModelFactory_GivenServiceConflictNode_NullResourceID()
        {
            //------------Setup for test--------------------------
            var adapter   = new Mock <IApplicationAdaptor>();
            var severRepo = new Mock <IServerRepository>();

            severRepo.Setup(p => p.ActiveServer).Returns(new Mock <IServer>().Object);
            CustomContainer.Register(severRepo.Object);
            adapter.Setup(p => p.TryFindResource(It.IsAny <object>())).Returns(new object());
            CustomContainer.Register(adapter.Object);
            var node = new Mock <IConflictTreeNode>();
            var contextualResource = new Mock <IContextualResourceModel>();
            var value      = new DsfActivity();
            var assignStep = new FlowStep
            {
                Action = value
            };
            var currentResourceModel = Dev2MockFactory.SetupResourceModelMock();

            node.Setup(p => p.Activity).Returns(value);
            contextualResource.Setup(r => r.Environment.ResourceRepository.LoadContextualResourceModel(Guid.Empty)).Returns((IContextualResourceModel)null);
            var toolConflictItem = new ToolConflictItem(new ViewModels.Merge.Utils.ConflictRowList(new Mock <IConflictModelFactory>().Object, new Mock <IConflictModelFactory>().Object, new List <ConflictTreeNode>(), new List <ConflictTreeNode>()), ViewModels.Merge.Utils.ConflictRowList.Column.Current);
            //------------Execute Test---------------------------

            var completeConflict = new ConflictModelFactory(toolConflictItem, contextualResource.Object, node.Object);

            //------------Assert Results-------------------------
            Assert.IsNotNull(completeConflict);
            adapter.Verify(p => p.TryFindResource(It.IsAny <object>()));
            var mergeToolModel = completeConflict.CreateModelItem(toolConflictItem, node.Object);

            Assert.AreEqual("DsfActivity", mergeToolModel.MergeDescription);
            Assert.AreEqual(typeof(ServiceDesignerViewModel).FullName, ((ToolConflictItem)mergeToolModel).ActivityDesignerViewModel.GetType().FullName);
        }
Exemplo n.º 11
0
        public void DsfActivityFactory_UnitTest_ResourceAndEnvironmentIDAssigned_Done()
        {
            var expectedResourceID    = Guid.NewGuid();
            var expectedEnvironmentID = Guid.NewGuid();

            var activity = new DsfActivity();

            var environment = new Mock <IEnvironmentModel>();

            environment.Setup(e => e.ID).Returns(expectedEnvironmentID);

            var model = new Mock <IContextualResourceModel>();

            model.Setup(m => m.ResourceType).Returns(ResourceType.Service);
            model.Setup(m => m.ID).Returns(expectedResourceID);
            model.Setup(m => m.Environment).Returns(environment.Object);
            model.Setup(m => m.WorkflowXaml).Returns(new StringBuilder("<root/>"));
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty);

            DsfActivityFactory.CreateDsfActivity(model.Object, activity, false, environmentRepository, false);

            var actualResourceID    = Guid.Parse(activity.ResourceID.Expression.ToString());
            var actualEnvironmentID = Guid.Parse(activity.EnvironmentID.Expression.ToString());

            Assert.AreEqual(expectedResourceID, actualResourceID, "DsfActivityFactory did not assign the resource ID.");
            Assert.AreEqual(expectedEnvironmentID, actualEnvironmentID, "DsfActivityFactory did not assign the environment ID.");
        }
Exemplo n.º 12
0
        public void DsfActivityFactory_CreateDsfActivity_WhenLocalEnviromentIsActiveAndActivityFromRemoteEnvironment_ExpectRemoteEnviromentID()
        {
            //------------Setup for test--------------------------
            var expectedResourceID    = Guid.NewGuid();
            var expectedEnvironmentID = Guid.NewGuid();

            var activity = new DsfActivity();

            var environment = new Mock <IEnvironmentModel>();

            environment.Setup(e => e.ID).Returns(expectedEnvironmentID);

            var model = new Mock <IContextualResourceModel>();

            model.Setup(m => m.ResourceType).Returns(ResourceType.Service);
            model.Setup(m => m.ID).Returns(expectedResourceID);
            model.Setup(m => m.Environment).Returns(environment.Object);
            model.Setup(m => m.ServerResourceType).Returns("Workflow");
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty); // Set the active environment

            //------------Execute Test---------------------------
            DsfActivityFactory.CreateDsfActivity(model.Object, activity, false, environmentRepository, true);

            //------------Assert Results-------------------------
            StringAssert.Contains(((Literal <string>)(activity.Type.Expression)).Value, "Workflow");
            Assert.AreEqual(expectedEnvironmentID.ToString(), activity.EnvironmentID.Expression.ToString());
        }
Exemplo n.º 13
0
        public void DsfActivityFactory_CreateDsfActivity_NullWorkflowXamlServerResourceTypeDbService_TypeIsDbService()
        {
            //------------Setup for test--------------------------
            var expectedResourceID    = Guid.NewGuid();
            var expectedEnvironmentID = Guid.NewGuid();

            var activity = new DsfActivity();

            var environment = new Mock <IEnvironmentModel>();

            environment.Setup(e => e.ID).Returns(expectedEnvironmentID);

            var model = new Mock <IContextualResourceModel>();

            model.Setup(m => m.ResourceType).Returns(ResourceType.Service);
            model.Setup(m => m.ID).Returns(expectedResourceID);
            model.Setup(m => m.Environment).Returns(environment.Object);
            model.Setup(m => m.ServerResourceType).Returns("DbService");
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty);

            //------------Execute Test---------------------------
            DsfActivityFactory.CreateDsfActivity(model.Object, activity, false, environmentRepository, false);

            //------------Assert Results-------------------------
            Assert.AreEqual("DbService", ((Literal <string>)(activity.Type.Expression)).Value);
        }
        public void WorkflowPropertyInterigator_SetActivityProperties_WhenNotNullXmlPayloadButNullProperty_ExpectAllPropertiesSet()
        {
            //------------Setup for test--------------------------
            IEventAggregator                 evtAg = new EventAggregator();
            Mock <IEnvironmentModel>         env   = new Mock <IEnvironmentModel>();
            Mock <IStudioResourceRepository> exp   = new Mock <IStudioResourceRepository>();

            env.Setup(e => e.Name).Returns("My Env");
            var resource = new ResourceModel(env.Object, evtAg)
            {
                WorkflowXaml = new StringBuilder("<x><HelpLink2>a:\\help.txt</HelpLink2></x>")
            };

            var activity = new DsfActivity("FriendlyName", String.Empty, "ServiceName", string.Empty, string.Empty, string.Empty);

            //------------Execute Test---------------------------

            WorkflowPropertyInterigator.SetActivityProperties(resource, ref activity);

            //------------Assert Results-------------------------
            Assert.IsTrue(activity.IsWorkflow);
            Assert.AreEqual("Workflow", activity.Type.Expression.ToString());
            Assert.AreEqual("My Env", activity.FriendlySourceName.Expression.ToString());
            Assert.IsNull(activity.HelpLink);
        }
        private DsfForEachActivity SetupArguments(string currentDl, string testData, enForEachType type, bool isInputMapping = false, string inputMapping = null, string from = null, string to = null, string csvIndexes = null, string numberExecutions = null)
        {
            var activityFunction = new ActivityFunc<string, bool>();
            DsfActivity activity = inputMapping != null ? CreateWorkflow(inputMapping, isInputMapping) : CreateWorkflow();

            activityFunction.Handler = activity;
            var id = Guid.NewGuid().ToString();
            DsfForEachActivity dsfForEachActivity = new DsfForEachActivity
            {
                DataFunc = activityFunction,
                ForEachType = type,
                NumOfExections = numberExecutions,
                From = @from,
                To = to,
                CsvIndexes = csvIndexes,
                UniqueID = id
            };
            TestStartNode = new FlowStep
            {
                Action = dsfForEachActivity
            };

            CurrentDl = testData;
            TestData = currentDl;
            return dsfForEachActivity;
        }
        public static DsfActivity CreateDsfActivity(IContextualResourceModel resource, DsfActivity activity,
                    bool ifNullCreateNew, IEnvironmentRepository environmentRepository, bool isDesignerLocalhost)
        {
            var activityToUpdate = activity;
            if(activityToUpdate == null)
            {
                if(ifNullCreateNew)
                {
                    activityToUpdate = new DsfActivity();
                }
                else
                {
                    return null;
                }
            }

            if(resource != null)
            {
                var activeEnvironment = environmentRepository.ActiveEnvironment;
                activityToUpdate.ResourceID = resource.ID;
                SetCorrectEnvironmentId(resource, activityToUpdate, isDesignerLocalhost, activeEnvironment);
                activityToUpdate = SetActivityProperties(resource, activityToUpdate);
            }

            activityToUpdate.ExplicitDataList = null;
            return activityToUpdate;
        }
        public void RedisCacheActivityFindMissingStrategy_GetActivityFields_CheckRedisCacheActivityWithDsfActivity_ExpectedAllFindMissingFieldsToBeReturned()
        {
            //--------------Arrange------------------------------
            var dsfActivity = new DsfActivity
            {
                InputMapping  = @"<Inputs><Input Name=""reg"" Source=""NUD2347"" DefaultValue=""NUD2347""><Validator Type=""Required"" /></Input><Input Name=""asdfsad"" Source=""registration223"" DefaultValue=""w3rt24324""><Validator Type=""Required"" /></Input><Input Name=""number"" Source=""[[number]]"" /></Inputs>",
                OutputMapping = @"<Outputs><Output Name=""vehicleVin"" MapsTo=""VIN"" Value="""" /><Output Name=""vehicleColor"" MapsTo=""VehicleColor"" Value="""" /><Output Name=""speed"" MapsTo=""speed"" Value="""" Recordset=""Fines"" /><Output Name=""date"" MapsTo=""date"" Value=""Fines.Date"" Recordset=""Fines"" /><Output Name=""location"" MapsTo=""location"" Value="""" Recordset=""Fines"" /></Outputs>"
            };
            var activity = new RedisCacheActivity
            {
                DisplayName  = "Redis Cache",
                ActivityFunc = { Handler = dsfActivity }
            };
            var findMissingStrategyFactory = new Dev2FindMissingStrategyFactory();
            var strategy = findMissingStrategyFactory.CreateFindMissingStrategy(enFindMissingType.RedisCache);

            //--------------Act----------------------------------
            var actual = strategy.GetActivityFields(activity);

            //--------------Assert-------------------------------
            var expected = new List <string> {
                "NUD2347", "registration223", "[[number]]", "Fines.Date", "5"
            };

            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 18
0
        public void GivenTheUnderlyingDroppedActivityIsANTool(string tool)
        {
            IDev2Activity innerActivity = null;

            switch (tool)
            {
            case "SelectAndApplyTestTool":
                innerActivity = new SelectAndApplyTestTool();

                break;

            case "Activity":
                innerActivity = new DsfActivity
                {
                    InputMapping  = BuildInputMappings(),
                    OutputMapping = BuildOutputMappings(),
                    ServiceName   = "SpecflowForeachActivityTest"
                };
                break;

            default:
                break;
            }
            scenarioContext.Add("innerActivity", innerActivity);
        }
Exemplo n.º 19
0
        public void DsfActivity_GetDebugOutputsFromEnv_ObjectNotNull()
        {
            //------------Setup for test--------------------------
            var environmentID = Guid.Empty;
            var env           = new ExecutionEnvironment();
            var dataObject    = new DsfDataObject(CurrentDl, ExecutionId)
            {
                ServerID                 = Guid.NewGuid(),
                ExecutingUser            = User,
                IsDebug                  = true,
                EnvironmentID            = environmentID,
                Environment              = env,
                IsRemoteInvokeOverridden = false,
                DataList                 = new StringBuilder(CurrentDl),
                IsServiceTestExecution   = true
            };

            env.Assign("[[list().Name]]", "bob", 0);
            //------------Execute Test---------------------------
            var act = new DsfActivity
            {
                ObjectName = "objectname",
                IsObject   = true,
                Outputs    = new List <IServiceOutputMapping>
                {
                    new ServiceOutputMapping("bob", "[[out]]", "list")
                }
            };
            var outputs = act.GetDebugOutputs(env, 0);

            //------------Assert Results-------------------------
            Assert.AreEqual(1, outputs[0].ResultsList.Count);
            Assert.AreEqual("objectname", outputs[0].ResultsList[0].Value);
        }
Exemplo n.º 20
0
        public void Equals_Given_SameOutputs_DifferentIndexes_ActivityTools_AreNotEqual()
        {
            //---------------Set up test pack-------------------
            var uniqueId = Guid.NewGuid().ToString();
            var outputs  = new List <Common.Interfaces.DB.IServiceOutputMapping>
            {
                new ServiceOutputMapping("d", "e", "f"),
                new ServiceOutputMapping("a", "b", "c")
            };
            var outputs2 = new List <Common.Interfaces.DB.IServiceOutputMapping>
            {
                new ServiceOutputMapping("a", "b", "c"),
                new ServiceOutputMapping("d", "e", "f")
            };
            var activity = new DsfActivity {
                UniqueID = uniqueId, Outputs = outputs
            };
            var activity1 = new DsfActivity {
                UniqueID = uniqueId, Outputs = outputs2
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNull(activity);
            //---------------Execute Test ----------------------
            var @equals = activity.Equals(activity1);

            //---------------Test Result -----------------------
            Assert.IsFalse(@equals);
        }
        public void WorkerServicePropertyInterigator_SetActivityProperties_GetSourceNameFromResourceRepo()
        {
            //------------Setup for test--------------------------
            IEventAggregator                 evtAg = new EventAggregator();
            Mock <IEnvironmentModel>         env   = new Mock <IEnvironmentModel>();
            Mock <IStudioResourceRepository> exp   = new Mock <IStudioResourceRepository>();
            var resRepo = new Mock <IResourceRepository>();
            var srcRes  = new Mock <IResourceModel>();

            srcRes.Setup(a => a.DisplayName).Returns("bob");
            resRepo.Setup(a => a.FindSingle(It.IsAny <Expression <Func <IResourceModel, bool> > >(), false, false)).Returns(srcRes.Object);

            env.Setup(e => e.Name).Returns("My Env");
            var resource = new ResourceModel(env.Object, evtAg)
            {
                WorkflowXaml = new StringBuilder("<Action SourceName=\"TheSource\" Type=\"TheType\" SourceMethod=\"SourceMethod\" SourceID=\"123456\"></Action>")
            };

            resource.ServerResourceType = "TheType";
            var activity = new DsfActivity("FriendlyName", String.Empty, "ServiceName", string.Empty, string.Empty, string.Empty);

            //------------Execute Test---------------------------
            WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity, resRepo.Object);

            //------------Assert Results-------------------------
            Assert.IsFalse(activity.IsWorkflow);
            Assert.AreEqual("TheType", ((Literal <string>)(activity.Type.Expression)).Value);
            Assert.AreEqual("bob", activity.FriendlySourceName.Expression.ToString());
            Assert.AreEqual("SourceMethod", activity.ActionName.Expression.ToString());
        }
        public void WorkerServicePropertyInterigator_SetActivityProperties_GetSourceNameFromResourceRepo()
        {
            //------------Setup for test--------------------------
            IEventAggregator evtAg = new EventAggregator();
            Mock<IEnvironmentModel> env = new Mock<IEnvironmentModel>();
            Mock<IStudioResourceRepository> exp = new Mock<IStudioResourceRepository>();
            var resRepo = new Mock<IResourceRepository>();
            var srcRes = new Mock<IResourceModel>();
            srcRes.Setup(a => a.DisplayName).Returns("bob");
            resRepo.Setup(a => a.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), false, false)).Returns(srcRes.Object);

            env.Setup(e => e.Name).Returns("My Env");
            var resource = new ResourceModel(env.Object, evtAg) { WorkflowXaml = new StringBuilder("<Action SourceName=\"TheSource\" Type=\"TheType\" SourceMethod=\"SourceMethod\" SourceID=\"123456\"></Action>") };
            resource.ServerResourceType = "TheType";
            var activity = new DsfActivity("FriendlyName", String.Empty, "ServiceName", string.Empty, string.Empty, string.Empty);

            //------------Execute Test---------------------------
            WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity, resRepo.Object);

            //------------Assert Results-------------------------
            Assert.IsFalse(activity.IsWorkflow);
            Assert.AreEqual("TheType", ((Literal<string>)(activity.Type.Expression)).Value);
            Assert.AreEqual("bob", activity.FriendlySourceName.Expression.ToString());
            Assert.AreEqual("SourceMethod", activity.ActionName.Expression.ToString());
        }
Exemplo n.º 23
0
        static DsfActivity SetActivityProperties(IContextualResourceModel resource, DsfActivity activity)
        {
            switch (resource.ResourceType)
            {
            case ResourceType.WorkflowService:
                WorkflowPropertyInterigator.SetActivityProperties(resource, ref activity);
                break;

            case ResourceType.Service:
                WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity, resource.Environment.ResourceRepository);
                break;

            case ResourceType.Source:
                break;

            case ResourceType.Unknown:
                break;

            case ResourceType.Server:
                break;

            default:
                break;
            }
            return(activity);
        }
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity)
        {
            if(resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {
                var startIdx = resource.WorkflowXaml.IndexOf("<HelpLink>", 0, true);

                if(startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf("</HelpLink>", startIdx, true);

                    if(endIdx > 0)
                    {
                        startIdx += 10;
                        var len = (endIdx - startIdx);

                        activity.HelpLink = resource.WorkflowXaml.Substring(startIdx, len);
                    }
                }

            }

            if(resource.Environment != null) activity.FriendlySourceName = resource.Environment.Name;
            activity.IsWorkflow = true;
            activity.Type = "Workflow";
        }
Exemplo n.º 25
0
        public bool SetModelItemForServiceTypes(IDataObject dataObject)
        {
            if (dataObject != null && (dataObject.GetDataPresent(GlobalConstants.ExplorerItemModelFormat) || dataObject.GetDataPresent(GlobalConstants.UpgradedExplorerItemModelFormat)))
            {
                var  explorerItemModel = dataObject.GetData(GlobalConstants.UpgradedExplorerItemModelFormat);
                Guid envId             = new Guid();
                Guid resourceId        = new Guid();

                if (explorerItemModel == null)
                {
                    return(false);
                }
                IExplorerItemViewModel itemModel = explorerItemModel as IExplorerItemViewModel;
                if (itemModel != null)
                {
                    if (itemModel.Server != null)
                    {
                        envId = itemModel.Server.EnvironmentID;
                    }
                    resourceId = itemModel.ResourceId;
                }

                try
                {
                    IServer server   = ServerRepository.Instance.FindSingle(c => c.EnvironmentID == envId);
                    var     resource = server?.ResourceRepository.LoadContextualResourceModel(resourceId);

                    if (resource != null)
                    {
                        DsfActivity d = DsfActivityFactory.CreateDsfActivity(resource, null, true, ServerRepository.Instance, true);
                        d.ServiceName = d.DisplayName = d.ToolboxFriendlyName = resource.Category;
                        if (Application.Current != null && Application.Current.Dispatcher.CheckAccess() && Application.Current.MainWindow != null)
                        {
                            dynamic mvm = Application.Current.MainWindow.DataContext;
                            if (mvm != null && mvm.ActiveItem != null)
                            {
                                WorkflowDesignerUtils.CheckIfRemoteWorkflowAndSetProperties(d, resource, mvm.ActiveItem.Environment);
                            }
                        }

                        ModelItem modelItem = ModelItemUtils.CreateModelItem(d);
                        if (modelItem != null)
                        {
                            dynamic             mi = ModelItem;
                            ModelItemCollection activitiesCollection = mi.Activities;
                            activitiesCollection.Insert(activitiesCollection.Count, d);
                            return(true);
                        }
                    }
                }
                catch (RuntimeBinderException e)
                {
                    Dev2Logger.Error(e);
                }
            }
            return(false);
        }
Exemplo n.º 26
0
        public void DsfActivity_UpdateForEachInputs_WhenExecuted_ThrowsException()
        {
            //------------Setup for test--------------------------
            var dsfActivity = new DsfActivity();

            //------------Execute Test---------------------------
            dsfActivity.UpdateForEachInputs(new List <Tuple <string, string> >());
            //------------Assert Results-------------------------
        }
Exemplo n.º 27
0
        public void DsfActivity_GetForEachOutputs_WhenExecuted_ThrowsException()
        {
            //------------Setup for test--------------------------
            var dsfActivity = new DsfActivity();

            //------------Execute Test---------------------------
            dsfActivity.GetForEachOutputs();
            //------------Assert Results-------------------------
        }
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity, IResourceRepository resourceRepository)
        {
            activity.IsWorkflow = false;

            if (resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {
                var startIdx = resource.WorkflowXaml.IndexOf("<Action ", 0, true);

                if (startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf(">", startIdx, true);
                    if (endIdx > 0)
                    {
                        var len      = (endIdx - startIdx) + 1;
                        var fragment = resource.WorkflowXaml.Substring(startIdx, len);

                        fragment += "</Action>";
                        fragment  = fragment.Replace("&", "&amp;");
                        XmlDocument document = new XmlDocument();

                        document.LoadXml(fragment);

                        if (document.DocumentElement != null)
                        {
                            XmlNode node = document.SelectSingleNode("//Action");
                            if (node != null)
                            {
                                if (node.Attributes != null)
                                {
                                    var attr = node.Attributes["SourceName"];
                                    if (attr != null)
                                    {
                                        if (resourceRepository != null && node.Attributes["SourceID"] != null)
                                        {
                                            Guid sourceId;
                                            Guid.TryParse(node.Attributes["SourceID"].Value, out sourceId);
                                            activity.FriendlySourceName = resourceRepository.FindSingle(a => !(a.ID.ToString() != sourceId.ToString()), false).DisplayName;
                                        }
                                        else
                                        {
                                            activity.FriendlySourceName = attr.Value;
                                        }
                                    }

                                    attr = node.Attributes["SourceMethod"];
                                    if (attr != null)
                                    {
                                        activity.ActionName = attr.Value;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            activity.Type = resource.ServerResourceType;
        }
        public static void SetActivityProperties(IContextualResourceModel resource, ref DsfActivity activity, IResourceRepository resourceRepository)
        {
            activity.IsWorkflow = false;

            if(resource.WorkflowXaml != null && resource.WorkflowXaml.Length > 0)
            {

                var startIdx = resource.WorkflowXaml.IndexOf("<Action ", 0, true);

                if(startIdx >= 0)
                {
                    var endIdx = resource.WorkflowXaml.IndexOf(">", startIdx, true);
                    if(endIdx > 0)
                    {
                        var len = endIdx - startIdx + 1;
                        var fragment = resource.WorkflowXaml.Substring(startIdx, len);

                        fragment += "</Action>";
                        fragment = fragment.Replace("&", "&amp;");
                        XmlDocument document = new XmlDocument();

                        document.LoadXml(fragment);

                        if(document.DocumentElement != null)
                        {
                            XmlNode node = document.SelectSingleNode("//Action");
                            if(node != null)
                            {
                                if(node.Attributes != null)
                                {
                                    var attr = node.Attributes["SourceName"];
                                    if(attr != null)
                                    {
                                        if (resourceRepository != null && node.Attributes["SourceID"] != null)
                                        {
                                            Guid sourceId;
                                            Guid.TryParse( node.Attributes["SourceID"].Value, out sourceId);
                                            activity.FriendlySourceName = resourceRepository.FindSingle(a => !(a.ID.ToString() != sourceId.ToString()),false).DisplayName;
                                        }
                                        else
                                        activity.FriendlySourceName = attr.Value;
                                    }

                                    attr = node.Attributes["SourceMethod"];
                                    if(attr != null)
                                    {
                                        activity.ActionName = attr.Value;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            activity.Type = resource.ServerResourceType;
        }
Exemplo n.º 30
0
        public void DsfActivity_Inputs_GivenValue_ShouldSetProperty()
        {
            //------------Setup for test--------------------------
            var dsfActivity = new DsfActivity();

            //------------Execute Test---------------------------
            dsfActivity.Inputs = new List <IServiceInput>();
            //------------Assert Results-------------------------
            Assert.IsNotNull(dsfActivity.Inputs);
        }
Exemplo n.º 31
0
 public static void CheckIfRemoteWorkflowAndSetProperties(DsfActivity dsfActivity, IContextualResourceModel resource, IEnvironmentModel contextEnv)
 {
     if (resource != null && resource.ResourceType == ResourceType.WorkflowService && contextEnv != null)
     {
         if (contextEnv.ID != resource.Environment.ID)
         {
             dsfActivity.ServiceUri    = resource.Environment.Connection.WebServerUri.AbsoluteUri;
             dsfActivity.ServiceServer = resource.Environment.ID;
         }
     }
 }
Exemplo n.º 32
0
        public void DsfActivity_GetState_ReturnsStateVariable()
        {
            //---------------Set up test pack-------------------
            //------------Setup for test--------------------------
            var act = new DsfActivity();
            //------------Execute Test---------------------------
            var stateItems = act.GetState();

            //------------Assert Results-------------------------
            Assert.AreEqual(0, stateItems.Count());
        }
Exemplo n.º 33
0
        public void DsfActivity_GetFindMissingType_Executed_ReturnsDsfActivity()
        {
            //------------Setup for test--------------------------
            var dsfActivity = new DsfActivity();

            //------------Execute Test---------------------------
            var findMissingType = dsfActivity.GetFindMissingType();

            //------------Assert Results-------------------------
            Assert.AreEqual(enFindMissingType.DsfActivity, findMissingType);
        }
Exemplo n.º 34
0
        public void AddActivity(DsfActivity activity)
        {
            AddCategoryIfNotExists("Action Activities");
            var category = GetToolboxCategoryByName("Action Activities");

            if (category != null)
            {
                category.Tools.Add(new ToolboxItemWrapper(typeof(DsfActivity), activity.IconPath.Expression.ToString(), activity.ToolboxFriendlyName));
            }
            tools.UpdateLayout();
        }
Exemplo n.º 35
0
        /// <summary>
        /// Gets all the fields for a specific activity
        /// </summary>
        /// <param name="activity">The activity that the fields will be retrieved from</param>
        /// <returns>Returns all the fields in a list of strings</returns>
        public List <string> GetActivityFields(object activity)
        {
            List <string> results = new List <string>();
            DsfActivity   act     = activity as DsfActivity;

            if (act != null)
            {
                if (!string.IsNullOrEmpty(act.ServiceName))
                {
                    results.Add(act.ServiceName);
                }

                if (!string.IsNullOrEmpty(act.InputMapping))
                {
                    XElement inputMappingElement  = XElement.Parse(act.InputMapping);
                    string   inputElement         = "Input";
                    IEnumerable <XElement> inputs = inputMappingElement.DescendantsAndSelf().Where(c => c.Name.ToString().Equals(inputElement, StringComparison.InvariantCultureIgnoreCase));
                    foreach (XElement element in inputs)
                    {
                        string val = element.Attribute("Source").Value;
                        if (!string.IsNullOrEmpty(val))
                        {
                            results.Add(val);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(act.OutputMapping))
                {
                    XElement outputMappingElement = XElement.Parse(act.OutputMapping);
                    string   outputElement        = "Output";
                    IEnumerable <XElement> inputs = outputMappingElement.DescendantsAndSelf().Where(c => c.Name.ToString().Equals(outputElement, StringComparison.InvariantCultureIgnoreCase));
                    foreach (XElement element in inputs)
                    {
                        string val = element.Attribute("Value").Value;
                        if (!string.IsNullOrEmpty(val))
                        {
                            results.Add(val);
                        }
                    }
                }

                if (!string.IsNullOrEmpty(act.OnErrorVariable))
                {
                    results.Add(act.OnErrorVariable);
                }

                if (!string.IsNullOrEmpty(act.OnErrorWorkflow))
                {
                    results.Add(act.OnErrorWorkflow);
                }
            }
            return(results);
        }
Exemplo n.º 36
0
        public static void CheckIfRemoteWorkflowAndSetProperties(DsfActivity dsfActivity, IContextualResourceModel resource, IEnvironmentModel contextEnv)
        {
            if(resource != null && resource.ResourceType == ResourceType.WorkflowService && contextEnv != null)
            {
                if(contextEnv.ID != resource.Environment.ID)
                {
                    dsfActivity.ServiceUri = resource.Environment.Connection.WebServerUri.AbsoluteUri;
                    dsfActivity.ServiceServer = resource.Environment.ID;

                }
                dsfActivity.FriendlySourceName = new InArgument<string>(resource.Environment.Connection.WebServerUri.Host);
            }
        }
 static DsfActivity SetActivityProperties(IContextualResourceModel resource, DsfActivity activity)
 {
     
     switch(resource.ResourceType)
     {
         case ResourceType.WorkflowService:
             WorkflowPropertyInterigator.SetActivityProperties(resource, ref activity);
             break;
         case ResourceType.Service:
             WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity,resource.Environment.ResourceRepository);
             break;
     }
     return activity;
 }
Exemplo n.º 38
0
        public void Given_WebActivityBackedByAModelItem_ExpectedTheServiceNamePropertySetsTheServiceNamePropertyOnTheModelItem()
        {
            DsfActivity Act = new DsfActivity();
            Act.ServiceName = "testResource";
            Act.InputMapping = @"<Inputs><Input Name=""Host"" Source=""Host"" DefaultValue=""mail.bellevuenet.co.za""><Validator Type=""Required"" /></Input><Input Name=""Port"" Source=""Port"" DefaultValue=""25""><Validator Type=""Required"" /></Input><Input Name=""From"" Source=""From"" DefaultValue=""*****@*****.**""><Validator Type=""Required"" /></Input><Input Name=""To"" Source=""To""><Validator Type=""Required"" /></Input><Input Name=""Subject"" Source=""Subject""><Validator Type=""Required"" /></Input><Input Name=""BodyType"" Source=""Bodytype"" DefaultValue=""html""><Validator Type=""Required"" /></Input><Input Name=""Body"" Source=""Body""><Validator Type=""Required"" /></Input><Input Name=""Attachment"" Source=""Attachment"" DefaultValue=""NONE""><Validator Type=""Required"" /></Input></Inputs>";
            Act.OutputMapping = @"<Outputs><Output Name=""FailureMessage"" MapsTo=""FailureMessage"" Value=""[[FailureMessage]]"" /><Output Name=""Message"" MapsTo=""Message"" Value=""[[Message]]"" /></Outputs>";
            ModelItem testItem = TestModelItemFactory.CreateModelItem(Act);

            string serviceName = "cake";

            IWebActivity webActivity = WebActivityFactory.CreateWebActivity(testItem, null, serviceName);

            Assert.AreEqual(serviceName, webActivity.ServiceName);
            Assert.AreEqual("DsfActivity", ModelItemUtils.GetProperty("DisplayName", testItem));
        }
Exemplo n.º 39
0
        public void DsfActivity_BeforeExecutionStart_EmptyResourceID_DoesNothing()
        {
            //------------Setup for test--------------------------
            DsfActivity act = new DsfActivity { InputMapping = ActivityStrings.DsfActivityInputMapping, OutputMapping = ActivityStrings.DsfActivityOutputMapping, ResourceID = new InArgument<Guid>(Guid.Empty) };
            List<DebugItem> inRes;
            List<DebugItem> outRes;
            //------------Execute Test---------------------------
            CheckPathOperationActivityDebugInputOutput(act, @"<ADL><scalar></scalar><Numeric><num></num></Numeric><CompanyName></CompanyName><Customer><FirstName></FirstName></Customer></ADL>",
                                                               "<ADL><scalar>scalarData</scalar><Numeric><num>1</num></Numeric><Numeric><num>2</num></Numeric><Numeric><num>3</num></Numeric><Numeric><num>4</num></Numeric><CompanyName>Dev2</CompanyName><Customer><FirstName>Wallis</FirstName></Customer></ADL>", out inRes, out outRes);

            // remove test datalist ;)

            //------------Assert Results-------------------------
            Assert.AreEqual(5, inRes.Count);
        }
        static void SetCorrectEnvironmentId(IContextualResourceModel resource, DsfActivity activity, bool isDesignerLocalhost, IEnvironmentModel activeEnvironment)
        {
            if(resource.Environment != null)
            {
                var idToUse = resource.Environment.ID;

                //// when we have an active remote environment that we are designing against, set it as local to that environment ;)
                if(activeEnvironment.ID == resource.Environment.ID && idToUse != Guid.Empty && !isDesignerLocalhost)
                {
                    idToUse = Guid.Empty;
                }

                activity.EnvironmentID = idToUse;
            }
        }
        public void GetActivityFieldsOffDsfActivityExpectedAllFindMissingFieldsToBeReturned()
        {
            var expectedOnError = new List<string> { "[[ErrorVar]]", "http://*****:*****@"<Inputs><Input Name=""reg"" Source=""NUD2347"" DefaultValue=""NUD2347""><Validator Type=""Required"" /></Input><Input Name=""asdfsad"" Source=""registration223"" DefaultValue=""w3rt24324""><Validator Type=""Required"" /></Input><Input Name=""number"" Source=""[[number]]"" /></Inputs>";
            activity.OutputMapping = @"<Outputs><Output Name=""vehicleVin"" MapsTo=""VIN"" Value="""" /><Output Name=""vehicleColor"" MapsTo=""VehicleColor"" Value="""" /><Output Name=""speed"" MapsTo=""speed"" Value="""" Recordset=""Fines"" /><Output Name=""date"" MapsTo=""date"" Value=""Fines.Date"" Recordset=""Fines"" /><Output Name=""location"" MapsTo=""location"" Value="""" Recordset=""Fines"" /></Outputs>";
            activity.OnErrorVariable = expectedOnError[0];
            activity.OnErrorWorkflow = expectedOnError[1];

            Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory();
            IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.DsfActivity);
            List<string> actual = strategy.GetActivityFields(activity);
            List<string> expected = new List<string> { "NUD2347", "registration223", "[[number]]", "Fines.Date", expectedOnError[0], expectedOnError[1] };
            CollectionAssert.AreEqual(expected, actual);
        }
Exemplo n.º 42
0
        public void WebActivity_IsConnected_PassThrough(bool retConnected, bool retLoaded, bool expected)
        {
            DsfActivity Act = new DsfActivity();
            Act.ServiceName = "testResource";
            Act.InputMapping = @"<Inputs><Input Name=""Host"" Source=""Host"" DefaultValue=""mail.bellevuenet.co.za""><Validator Type=""Required"" /></Input><Input Name=""Port"" Source=""Port"" DefaultValue=""25""><Validator Type=""Required"" /></Input><Input Name=""From"" Source=""From"" DefaultValue=""*****@*****.**""><Validator Type=""Required"" /></Input><Input Name=""To"" Source=""To""><Validator Type=""Required"" /></Input><Input Name=""Subject"" Source=""Subject""><Validator Type=""Required"" /></Input><Input Name=""BodyType"" Source=""Bodytype"" DefaultValue=""html""><Validator Type=""Required"" /></Input><Input Name=""Body"" Source=""Body""><Validator Type=""Required"" /></Input><Input Name=""Attachment"" Source=""Attachment"" DefaultValue=""NONE""><Validator Type=""Required"" /></Input></Inputs>";
            Act.OutputMapping = @"<Outputs><Output Name=""FailureMessage"" MapsTo=""FailureMessage"" Value=""[[FailureMessage]]"" /><Output Name=""Message"" MapsTo=""Message"" Value=""[[Message]]"" /></Outputs>";
            ModelItem testItem = TestModelItemFactory.CreateModelItem(Act);
            var resource = new Mock<IContextualResourceModel>();
            var env = new Mock<IEnvironmentModel>();
            resource.Setup(a => a.Environment).Returns(env.Object);
            env.Setup(a => a.IsConnected).Returns(retConnected);
            env.Setup(a => a.HasLoadedResources).Returns(retLoaded);
            string serviceName = "cake";

            IWebActivity webActivity = WebActivityFactory.CreateWebActivity(testItem, resource.Object, serviceName);
            Assert.AreEqual(expected,webActivity.IsNotAvailable());
        }
 public void GetActivityFieldsOffDsfForEachActivityWithADsfActivityInsideItExpectedAllFindMissingFieldsToBeReturned()
 {
     DsfActivity dsfActivity = new DsfActivity
                               {
                                   InputMapping = @"<Inputs><Input Name=""reg"" Source=""NUD2347"" DefaultValue=""NUD2347""><Validator Type=""Required"" /></Input><Input Name=""asdfsad"" Source=""registration223"" DefaultValue=""w3rt24324""><Validator Type=""Required"" /></Input><Input Name=""number"" Source=""[[number]]"" /></Inputs>",
                                   OutputMapping = @"<Outputs><Output Name=""vehicleVin"" MapsTo=""VIN"" Value="""" /><Output Name=""vehicleColor"" MapsTo=""VehicleColor"" Value="""" /><Output Name=""speed"" MapsTo=""speed"" Value="""" Recordset=""Fines"" /><Output Name=""date"" MapsTo=""date"" Value=""Fines.Date"" Recordset=""Fines"" /><Output Name=""location"" MapsTo=""location"" Value="""" Recordset=""Fines"" /></Outputs>"
                               };
     DsfForEachActivity activity = new DsfForEachActivity
                                   {
                                       ForEachElementName = "5",
                                       DataFunc = { Handler = dsfActivity }
                                   };
     Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory();
     IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.ForEach);
     List<string> actual = strategy.GetActivityFields(activity);
     List<string> expected = new List<string> { "NUD2347", "registration223", "[[number]]", "Fines.Date", "5" };
     CollectionAssert.AreEqual(expected, actual);
 }
        public void WorkflowPropertyInterigator_SetActivityProperties_WhenNullXmlPayload_ExpectSomePropertiesSet()
        {
            //------------Setup for test--------------------------
            IEventAggregator evtAg = new EventAggregator();
            Mock<IEnvironmentModel> env = new Mock<IEnvironmentModel>();
            Mock<IStudioResourceRepository> exp = new Mock<IStudioResourceRepository>();
            env.Setup(e => e.Name).Returns("My Env");
            var resource = new ResourceModel(env.Object, evtAg);

            var activity = new DsfActivity("FriendlyName", String.Empty, "ServiceName", string.Empty, string.Empty, string.Empty);
            //------------Execute Test---------------------------

            WorkflowPropertyInterigator.SetActivityProperties(resource, ref activity);

            //------------Assert Results-------------------------
            Assert.IsTrue(activity.IsWorkflow);
            Assert.AreEqual("Workflow", activity.Type.Expression.ToString());
            Assert.AreEqual("My Env", activity.FriendlySourceName.Expression.ToString());
        }
        public void WorkerServicePropertyInterigator_SetActivityProperties_WhenNotNullXML_ExpectPropertiesSet()
        {
            //------------Setup for test--------------------------
            IEventAggregator evtAg = new EventAggregator();
            Mock<IEnvironmentModel> env = new Mock<IEnvironmentModel>();
            Mock<IStudioResourceRepository> exp = new Mock<IStudioResourceRepository>();
            env.Setup(e => e.Name).Returns("My Env");
            var resource = new ResourceModel(env.Object, evtAg) { WorkflowXaml = new StringBuilder("<Action SourceName=\"TheSource\" Type=\"TheType\" SourceMethod=\"SourceMethod\"></Action>") };
            resource.ServerResourceType = "TheType";
            var activity = new DsfActivity("FriendlyName", String.Empty, "ServiceName", string.Empty, string.Empty, string.Empty);

            //------------Execute Test---------------------------
            WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity, null);

            //------------Assert Results-------------------------
            Assert.IsFalse(activity.IsWorkflow);
            Assert.AreEqual("TheType", ((Literal<string>)(activity.Type.Expression)).Value);
            Assert.AreEqual("TheSource", activity.FriendlySourceName.Expression.ToString());
            Assert.AreEqual("SourceMethod", activity.ActionName.Expression.ToString());
        }
        public void WorkerServicePropertyInterigator_SetActivityProperties_WhenNullXML_ExpectSomePropertiesSet()
        {
            //------------Setup for test--------------------------
            IEventAggregator evtAg = new EventAggregator();
            Mock<IEnvironmentModel> env = new Mock<IEnvironmentModel>();
            Mock<IStudioResourceRepository> exp = new Mock<IStudioResourceRepository>();
            env.Setup(e => e.Name).Returns("My Env");
            var resource = new ResourceModel(env.Object, evtAg);

            var activity = new DsfActivity("FriendlyName", String.Empty, "ServiceName", string.Empty, string.Empty, string.Empty);

            //------------Execute Test---------------------------
            WorkerServicePropertyInterigator.SetActivityProperties(resource, ref activity, null);

            //------------Assert Results-------------------------
            Assert.IsFalse(activity.IsWorkflow);
            Assert.IsNull(((Literal<string>)(activity.Type.Expression)).Value);
            Assert.IsNull(activity.FriendlySourceName);
            Assert.IsNull(activity.ActionName);
        }
        public void DsfActivityFactory_CreateDsfActivity_NullWorkflowXamlServerResourceTypeWebService_TypeIsWebService()
        {
            //------------Setup for test--------------------------
            var expectedResourceID = Guid.NewGuid();
            var expectedEnvironmentID = Guid.NewGuid();

            var activity = new DsfActivity();

            var environment = new Mock<IEnvironmentModel>();
            environment.Setup(e => e.ID).Returns(expectedEnvironmentID);

            var model = new Mock<IContextualResourceModel>();
            model.Setup(m => m.ResourceType).Returns(ResourceType.Service);
            model.Setup(m => m.ID).Returns(expectedResourceID);
            model.Setup(m => m.Environment).Returns(environment.Object);
            model.Setup(m => m.ServerResourceType).Returns("WebService");
            var environmentRepository = SetupEnvironmentRepo(Guid.Empty);

            //------------Execute Test---------------------------
            DsfActivityFactory.CreateDsfActivity(model.Object, activity, false, environmentRepository, false);

            //------------Assert Results-------------------------
            Assert.AreEqual("WebService", ((Literal<string>)(activity.Type.Expression)).Value);
        }
        public void SequenceActivityFindMissingStrategy_GetActivityFields_WithAssignAndDataMerge_ReturnsAllVariables()
        {
            //------------Setup for test--------------------------
            DsfMultiAssignActivity multiAssignActivity = new DsfMultiAssignActivity { FieldsCollection = new List<ActivityDTO> { new ActivityDTO("[[AssignRight1]]", "[[AssignLeft1]]", 1), new ActivityDTO("[[AssignRight2]]", "[[AssignLeft2]]", 2) } };

            DsfDataMergeActivity dataMergeActivity = new DsfDataMergeActivity { Result = "[[Result]]" };
            dataMergeActivity.MergeCollection.Add(new DataMergeDTO("[[rec().a]]", "Index", "6", 1, "[[b]]", "Left"));

            DsfActivity dsfActivity = new DsfActivity { InputMapping = @"<Inputs><Input Name=""reg"" Source=""NUD2347"" DefaultValue=""NUD2347""><Validator Type=""Required"" /></Input><Input Name=""asdfsad"" Source=""registration223"" DefaultValue=""w3rt24324""><Validator Type=""Required"" /></Input><Input Name=""number"" Source=""[[number]]"" /></Inputs>", OutputMapping = @"<Outputs><Output Name=""vehicleVin"" MapsTo=""VIN"" Value="""" /><Output Name=""vehicleColor"" MapsTo=""VehicleColor"" Value="""" /><Output Name=""speed"" MapsTo=""speed"" Value="""" Recordset=""Fines"" /><Output Name=""date"" MapsTo=""date"" Value=""Fines.Date"" Recordset=""Fines"" /><Output Name=""location"" MapsTo=""location"" Value="""" Recordset=""Fines"" /></Outputs>" };
            DsfForEachActivity forEachActivity = new DsfForEachActivity { ForEachElementName = "5", DataFunc = { Handler = dsfActivity } };

            DsfSequenceActivity activity = new DsfSequenceActivity();
            activity.Activities.Add(multiAssignActivity);
            activity.Activities.Add(dataMergeActivity);
            activity.Activities.Add(forEachActivity);

            Dev2FindMissingStrategyFactory fac = new Dev2FindMissingStrategyFactory();
            IFindMissingStrategy strategy = fac.CreateFindMissingStrategy(enFindMissingType.Sequence);
            //------------Execute Test---------------------------
            List<string> actual = strategy.GetActivityFields(activity);
            //------------Assert Results-------------------------
            List<string> expected = new List<string> { "[[AssignRight1]]", "[[AssignLeft1]]", "[[AssignRight2]]", "[[AssignLeft2]]", "[[b]]", "[[rec().a]]", "6", "[[Result]]", "NUD2347", "registration223", "[[number]]", "Fines.Date", "5" };
            CollectionAssert.AreEqual(expected, actual);
        }
        public void ServiceDesignerViewModel_WhenResourceHasSource_ShouldGetSourceName()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();

            var connection = new Mock<IEnvironmentConnection>();
            connection.Setup(conn => conn.ServerEvents).Returns(new EventPublisher());

            var environmentID = Guid.NewGuid();
            var environment = new Mock<IEnvironmentModel>();
            environment.Setup(e => e.Connection).Returns(connection.Object);
            environment.Setup(e => e.ID).Returns(environmentID);
            environment.Setup(e => e.IsConnected).Returns(true);
            environment.Setup(model => model.IsLocalHost).Returns(false);
            environment.Setup(e => e.IsLocalHostCheck()).Returns(false);

            var errors = new ObservableReadOnlyList<IErrorInfo>();

            var resourceModel = new Mock<IContextualResourceModel>();
            resourceModel.Setup(r => r.ResourceName).Returns("TestResource");
            resourceModel.Setup(r => r.ServerID).Returns(Guid.NewGuid());
            resourceModel.Setup(r => r.WorkflowXaml).Returns(new StringBuilder("<root/>"));
            resourceModel.Setup(m => m.Errors).Returns(errors);
            resourceModel.Setup(m => m.ID).Returns(resourceID);
            resourceModel.Setup(m => m.Environment).Returns(environment.Object);
            resourceModel.Setup(m => m.GetErrors(It.IsAny<Guid>())).Returns(errors);
            resourceModel.Setup(m => m.HasErrors).Returns(() => false);
            resourceModel.SetupProperty(m => m.IsValid);
            resourceModel.Setup(m => m.RemoveError(It.IsAny<IErrorInfo>())).Callback((IErrorInfo error) => errors.Remove(error));

            resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
            var dataListViewModel = new DataListViewModel();
            dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
            dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
            DataListSingleton.SetDataList(dataListViewModel);

            var rootModel = CreateResourceModel(resourceID);

            var envRepository = new Mock<IEnvironmentRepository>();
            envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
            envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);


            var activity = new DsfActivity
            {
                ResourceID = new InArgument<Guid>(resourceID),
                EnvironmentID = new InArgument<Guid>(Guid.Empty),
                UniqueID = Guid.NewGuid().ToString(),
                SimulationMode = SimulationMode.OnDemand,
                InputMapping = "<Inputs><Input Name=\"n1\" Source=\"[[n1]]\" /></Inputs>",
                OutputMapping = "<Outputs><Output Name=\"n1\" MapsTo=\"[[n1]]\" Value=\"[[n1]]\" /></Outputs>"
            };

            var modelItem = CreateModelItem(activity);
            var resRepo = new Mock<IResourceRepository>();
            var srcRes = new Mock<IResourceModel>();
            srcRes.Setup(a => a.DisplayName).Returns("bob");
            resRepo.Setup(a => a.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), false, false)).Returns(srcRes.Object);
            environment.Setup(a => a.ResourceRepository).Returns(resRepo.Object);
            //------------Execute Test---------------------------
            var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object);
            //------------Assert Results-------------------------
            Assert.AreEqual("bob", viewModel.Properties.FirstOrDefault(a => a.Key == "Source :").Value);

        }
        public void ServiceDesignerViewModel_WhenRemoteEnvironmentLoads_ShouldNotSetVersionMemoIfCorrect()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();

            var connection = new Mock<IEnvironmentConnection>();
            connection.Setup(conn => conn.ServerEvents).Returns(new EventPublisher());

            var environmentID = Guid.NewGuid();


            var environment = new Mock<IEnvironmentModel>();
            environment.Setup(e => e.Connection).Returns(connection.Object);
            environment.Setup(e => e.ID).Returns(environmentID);
            environment.Setup(e => e.IsConnected).Returns(true);
            environment.Setup(model => model.IsLocalHost).Returns(false);
            environment.Setup(model => model.IsLocalHostCheck()).Returns(false);

            var errors = new ObservableReadOnlyList<IErrorInfo>();

            var resourceModel = new Mock<IContextualResourceModel>();
            resourceModel.Setup(r => r.ResourceName).Returns("TestResource");
            resourceModel.Setup(r => r.ServerID).Returns(Guid.NewGuid());
            resourceModel.Setup(r => r.WorkflowXaml).Returns(new StringBuilder("<root/>"));
            resourceModel.Setup(m => m.Errors).Returns(errors);
            resourceModel.Setup(m => m.ID).Returns(resourceID);
            resourceModel.Setup(m => m.Environment).Returns(environment.Object);
            resourceModel.Setup(m => m.GetErrors(It.IsAny<Guid>())).Returns(errors);
            resourceModel.Setup(m => m.HasErrors).Returns(() => false);
            resourceModel.SetupProperty(m => m.IsValid);
            resourceModel.Setup(m => m.RemoveError(It.IsAny<IErrorInfo>())).Callback((IErrorInfo error) => errors.Remove(error));

            resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");

            var resources = new Mock<IResourceRepository>();
            // ReSharper disable MaximumChainedReferences
            resources.Setup(a => a.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), true, false))
                  .Callback((Expression<Func<IResourceModel, bool>> expression, bool b,bool c) => Assert.IsTrue(expression.ToString().Contains("c => (c.ID == ")))
                  .Returns(resourceModel.Object).Verifiable();
            // ReSharper restore MaximumChainedReferences
            environment.Setup(a => a.ResourceRepository).Returns(resources.Object);
            var dataListViewModel = new DataListViewModel();
            dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
            dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
            DataListSingleton.SetDataList(dataListViewModel);

            var rootModel = CreateResourceModel(resourceID);

            var envRepository = new Mock<IEnvironmentRepository>();
            envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
            envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);

            var activity = new DsfActivity
            {
                ResourceID = new InArgument<Guid>(resourceID),
                EnvironmentID = new InArgument<Guid>(Guid.Empty),
                UniqueID = Guid.NewGuid().ToString(),
                SimulationMode = SimulationMode.OnDemand,
                InputMapping = "<Inputs></Inputs>",
                OutputMapping = "<Outputs></Outputs>"
            };

            var modelItem = CreateModelItem(activity);
            var worker = new Mock<IAsyncWorker>();
            // ReSharper disable MaximumChainedReferences
            worker.Setup(a => a.Start(It.IsAny<System.Action>(), It.IsAny<System.Action>())).Callback(
                // ReSharper restore MaximumChainedReferences
                (
                    System.Action a, System.Action b) =>
                {
                    a.Invoke();
                    b.Invoke();
                }
                );
            //------------Execute Test---------------------------
            // ReSharper disable UnusedVariable
            var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object, worker.Object);
            // ReSharper restore UnusedVariable
            environment.Setup(a => a.IsConnected).Returns(true);
            connection.Setup(a => a.Verify(It.IsAny<Action<ConnectResult>>(), true)).Verifiable();
            environment.Raise((a => a.ResourcesLoaded += null), new ResourcesLoadedEventArgs { Model = environment.Object });

            //------------Assert Results-------------------------
            Assert.IsTrue(viewModel.LastValidationMemo.Errors.Count == 0);

        }
 public void TestCheckIfRemoteWorkflowAndSetProperties(DsfActivity dsfActivity, IContextualResourceModel resource, IEnvironmentModel environmentModel)
 {
     WorkflowDesignerUtils.CheckIfRemoteWorkflowAndSetProperties(dsfActivity, resource, environmentModel);
 }
        public void ServiceDesignerViewModel_InitializeResourceIDNull_StillCorrectlySetsUp()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();

            var resourceModel = CreateResourceModel(Guid.Empty, false);
            resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");

            var dataListViewModel = new DataListViewModel();
            dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
            dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
            DataListSingleton.SetDataList(dataListViewModel);

            var rootModel = CreateResourceModel(Guid.Empty);

            var envRepository = new Mock<IEnvironmentRepository>();
            envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
            envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);

            var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(Guid.Empty), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand };

            var modelItem = CreateModelItem(activity);

            //------------Execute Test---------------------------
            var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object);
            //------------Assert Results-------------------------
            Assert.IsNotNull(viewModel.ResourceModel);
            var inputMapping = viewModel.ModelItem.GetProperty<string>("InputMapping");
            var outputMapping = viewModel.ModelItem.GetProperty<string>("OutputMapping");

            Assert.AreEqual("<Inputs><Input Name=\"n1\" Source=\"[[n1]]\" /></Inputs>", inputMapping);
            Assert.AreEqual("<Outputs><Output Name=\"n1\" MapsTo=\"[[n1]]\" Value=\"[[n1]]\" /></Outputs>", outputMapping);

        }
        public void ServiceDesignerViewModel_WhenRemoteEnvironmentLoads_ShouldUseNameToFindEnvironment()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.Empty;

            var connection = new Mock<IEnvironmentConnection>();
            connection.Setup(conn => conn.ServerEvents).Returns(new EventPublisher());

            var environmentID = Guid.NewGuid();


            var environment = new Mock<IEnvironmentModel>();
            environment.Setup(e => e.Connection).Returns(connection.Object);
            environment.Setup(e => e.ID).Returns(environmentID);
            environment.Setup(e => e.IsConnected).Returns(true);
            environment.Setup(model => model.IsLocalHost).Returns(false);
            environment.Setup(e => e.IsLocalHostCheck()).Returns(false);

            var errors = new ObservableReadOnlyList<IErrorInfo>();

            var resourceModel = new Mock<IContextualResourceModel>();
            resourceModel.Setup(r => r.ResourceName).Returns("TestResource").Verifiable();
            resourceModel.Setup(r => r.ServerID).Returns(Guid.NewGuid());
            resourceModel.Setup(r => r.WorkflowXaml).Returns(new StringBuilder("<root/>"));
            resourceModel.Setup(m => m.Errors).Returns(errors);
            resourceModel.Setup(m => m.ID).Returns(resourceID);
            resourceModel.Setup(m => m.Environment).Returns(environment.Object);
            resourceModel.Setup(m => m.GetErrors(It.IsAny<Guid>())).Returns(errors);
            resourceModel.Setup(m => m.HasErrors).Returns(() => false);
            resourceModel.SetupProperty(m => m.IsValid);
            resourceModel.Setup(m => m.RemoveError(It.IsAny<IErrorInfo>())).Callback((IErrorInfo error) => errors.Remove(error));

            resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");

            var resources = new Mock<IResourceRepository>();

            environment.Setup(a => a.ResourceRepository).Returns(resources.Object);
            var dataListViewModel = new DataListViewModel();
            dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
            dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
            DataListSingleton.SetDataList(dataListViewModel);

            var rootModel = CreateResourceModel(resourceID);

            var envRepository = new Mock<IEnvironmentRepository>();
            envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
            envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);

            var activity = new DsfActivity
            {
                ServiceName = "bob",
                ResourceID = new InArgument<Guid>(resourceID),
                EnvironmentID = new InArgument<Guid>(Guid.Empty),
                UniqueID = Guid.Empty.ToString(),
                SimulationMode = SimulationMode.OnDemand,
                InputMapping = "<Inputs><Input Name=\"n1\" Source=\"[[n1]]\" /></Inputs>",
                OutputMapping = "<Outputs><Output Name=\"n1\" MapsTo=\"[[n1]]\" Value=\"[[n1]]\" /></Outputs>"
            };

            var modelItem = CreateModelItem(activity);
            var worker = new Mock<IAsyncWorker>();
            // ReSharper disable MaximumChainedReferences
            worker.Setup(a => a.Start(It.IsAny<System.Action>(), It.IsAny<System.Action>()))
                .Callback((System.Action a, System.Action b) =>
                // ReSharper restore MaximumChainedReferences
                {
                    a.Invoke();
                    b.Invoke();
                }
                );
            //------------Execute Test---------------------------
            // ReSharper disable UnusedVariable


            var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object, worker.Object);
            var webFact = new Mock<IWebActivityFactory>();
            var wa = new Mock<IWebActivity>();
            // ReSharper disable MaximumChainedReferences
            webFact.Setup(
                a => a.CreateWebActivity(It.IsAny<Object>(), It.IsAny<IContextualResourceModel>(), It.IsAny<string>())).Returns(wa.Object).Verifiable();
            // ReSharper restore MaximumChainedReferences
            viewModel.ActivityFactory = webFact.Object;

            var mappingF = new Mock<IDataMappingViewModelFactory>();
            var mapping = new Mock<IDataMappingViewModel>();
            mapping.Setup(a => a.GetOutputString(It.IsAny<IList<IInputOutputViewModel>>())).Returns("bob");
            // ReSharper disable once MaximumChainedReferences
            mappingF.Setup(a => a.CreateModel(It.IsAny<IWebActivity>(), It.IsAny<NotifyCollectionChangedEventHandler>()))
                    .Returns(mapping.Object);
            viewModel.MappingFactory = mappingF.Object;

            // ReSharper restore UnusedVariable
            // ReSharper disable MaximumChainedReferences
            // ReSharper disable MaximumChainedReferences
            resources.Setup(a => a.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), true, false))
                .Returns(resourceModel.Object)
                .Callback((Expression<Func<IResourceModel, bool>> expression, bool b) => Assert.IsTrue(expression.ToString().Contains("c => (c.ResourceName == ")))

                .Verifiable();
            // ReSharper restore MaximumChainedReferences
            environment.Setup(a => a.IsConnected).Returns(true);

            environment.Raise((a => a.ResourcesLoaded += null), new ResourcesLoadedEventArgs { Model = environment.Object });

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

            Assert.IsTrue(viewModel.LastValidationMemo.Errors.First().Message.Contains("Incorrect Version. The remote workflow has changed.Please refresh"));

        }
Exemplo n.º 54
0
        private DsfActivity CreateWorkflow(string mapping, bool isInputMapping)
        {
            DsfActivity activity = new DsfActivity();
            if(isInputMapping)
            {
                activity.InputMapping = mapping;
                activity.OutputMapping = ActivityStrings.ForEach_Output_Mapping;
            }
            else
            {
                activity.InputMapping = ActivityStrings.ForEach_Input_Mapping;
                activity.OutputMapping = mapping;
            }
            activity.ServiceName = "MyTestService";

            TestData = "<ADL><innerrecset><innerrec></innerrec><innerrec2></innerrec2><innerdate></innerdate></innerrecset><innertesting><innertest></innertest></innertesting><innerScalar></innerScalar></ADL>";

            return activity;
        }
        public void ServiceDesignerViewModel_InitializeWhenEnvironmentModelOnOtherServer_StillCorrectlySetsUp()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();

            var resourceModel = CreateResourceModel(Guid.Empty, false);
            ISetup<IContextualResourceModel, string> setupResourceModel = resourceModel.Setup(model => model.DataList);
            setupResourceModel.Returns("<DataList><n1/></DataList>");


            var rootModel = CreateResourceModel(Guid.Empty);

            var envRepository = new Mock<IEnvironmentRepository>();
            ISetup<IEnvironmentRepository, IEnvironmentModel> setupFindSingle = envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>()));
            setupFindSingle.Returns((IEnvironmentModel)null);
            ISetup<IEnvironmentRepository, IEnvironmentModel> setupActiveEnvironment = envRepository.Setup(r => r.ActiveEnvironment);
            setupActiveEnvironment.Returns(resourceModel.Object.Environment);

            var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(rootModel.Object.Environment.ID), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand };

            var modelItem = CreateModelItem(activity);

            //------------Execute Test---------------------------
            var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object);
            //------------Assert Results-------------------------
            Assert.IsNotNull(viewModel.ResourceModel);

        }
Exemplo n.º 56
0
        private DsfActivity CreateWorkflow()
        {
            DsfActivity activity = new DsfActivity
                {
                    ServiceName = "MyTestService",
                    InputMapping = ActivityStrings.ForEach_Input_Mapping,
                    OutputMapping = ActivityStrings.ForEach_Output_Mapping
                   
                };

            TestData = "<ADL><innerrecset><innerrec></innerrec><innerrec2></innerrec2><innerdate></innerdate></innerrecset><innertesting><innertest></innertest></innertesting><innerScalar></innerScalar></ADL>";

            return activity;
        }
        static ServiceDesignerViewModel GenerateServiceDesignerViewModel(string name, Mock<IContextualResourceModel> myModel = null, string type = null, string serviceURI = null)
        {

            var resourceID = Guid.NewGuid();
            var rootModel = myModel;

            if (myModel == null)
            {
                rootModel = new Mock<IContextualResourceModel>();
                rootModel.Setup(m => m.Errors.Count).Returns(0);
                rootModel.Setup(m => m.GetErrors(It.IsAny<Guid>())).Returns(new List<IErrorInfo>());
            }

            var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(Guid.Empty), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand, ServiceName = name };

            if (type != null)
            {
                activity.Type = type;
            }

            if (serviceURI != null)
            {
                activity.ServiceUri = serviceURI;
            }

            var modelItem = CreateModelItem(activity);

            // setup the resource repository
            var resourceRepository = new Mock<IResourceRepository>();

            resourceRepository.Setup(r => r.IsLoaded).Returns(true);
            resourceRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IResourceModel, bool>>>(), true, false)).Returns(rootModel.Object);

            // setup active environment
            var activeEnvironment = new Mock<IEnvironmentModel>();
            activeEnvironment.Setup(a => a.IsLocalHostCheck()).Returns(false);
            activeEnvironment.Setup(a => a.IsLocalHost).Returns(false);
            activeEnvironment.Setup(a => a.HasLoadedResources).Returns(true);
            activeEnvironment.Setup(a => a.IsConnected).Returns(true);
            activeEnvironment.Setup(a => a.ResourceRepository).Returns(resourceRepository.Object);

            // setup the rootModel to return the insane levels of nested junk
            rootModel.Setup(r => r.Environment).Returns(activeEnvironment.Object);

            // setup the environment repository
            var environmentRepository = new Mock<IEnvironmentRepository>();
            environmentRepository.Setup(e => e.ActiveEnvironment).Returns(activeEnvironment.Object);

            // ReSharper disable ObjectCreationAsStatement
            var model = new ServiceDesignerViewModel(modelItem, rootModel.Object, environmentRepository.Object, new Mock<IEventAggregator>().Object);
            // ReSharper restore ObjectCreationAsStatement
            return model;
        }
 // ReSharper disable once UnusedParameter.Local
 static ModelItem CreateModelItem(DsfActivity activity)
 {
     return ModelItemUtils.CreateModelItem(activity);
 }
        public void ServiceDesingerViewModel_IsAsyncVisible_NotWorkflowResource_False()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();

            var resourceModel = CreateResourceModel(Guid.Empty, false);
            resourceModel.Setup(model => model.ResourceType).Returns(Studio.Core.AppResources.Enums.ResourceType.Service);
            resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
            var dataListViewModel = new DataListViewModel();
            dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
            dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
            DataListSingleton.SetDataList(dataListViewModel);

            var rootModel = CreateResourceModel(Guid.Empty);

            var envRepository = new Mock<IEnvironmentRepository>();
            envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
            envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);

            var resourceType = resourceModel.Object.ResourceType.ToString();
            var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(Guid.Empty), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand, Type = new InArgument<string>(resourceType) };

            var modelItem = CreateModelItem(activity);
            //------------Execute Test---------------------------
            var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object);
            //------------Assert Results-------------------------
            Assert.IsFalse(viewModel.IsAsyncVisible);
        }
        public void ServiceDesingerViewModel_SetRunWorkflowAsync_True_OutputMappingEnabledFalse()
        {
            //------------Setup for test--------------------------
            var resourceID = Guid.NewGuid();

            var resourceModel = CreateResourceModel(Guid.Empty, false);
            resourceModel.Setup(model => model.DataList).Returns("<DataList><n1/></DataList>");
            var dataListViewModel = new DataListViewModel();
            dataListViewModel.InitializeDataListViewModel(resourceModel.Object);
            dataListViewModel.ScalarCollection.Add(new DataListItemModel("n1"));
            DataListSingleton.SetDataList(dataListViewModel);

            var rootModel = CreateResourceModel(Guid.Empty);

            var envRepository = new Mock<IEnvironmentRepository>();
            envRepository.Setup(r => r.FindSingle(It.IsAny<Expression<Func<IEnvironmentModel, bool>>>())).Returns(resourceModel.Object.Environment);
            envRepository.Setup(r => r.ActiveEnvironment).Returns(resourceModel.Object.Environment);

            var activity = new DsfActivity { ResourceID = new InArgument<Guid>(resourceID), EnvironmentID = new InArgument<Guid>(Guid.Empty), UniqueID = Guid.NewGuid().ToString(), SimulationMode = SimulationMode.OnDemand };

            var modelItem = CreateModelItem(activity);
            var viewModel = new ServiceDesignerViewModel(modelItem, rootModel.Object, envRepository.Object, new Mock<IEventAggregator>().Object) { RunWorkflowAsync = true };
            //------------Execute Test---------------------------
            //------------Assert Results-------------------------
            Assert.IsTrue(viewModel.RunWorkflowAsync);
            Assert.IsFalse(viewModel.OutputMappingEnabled);
        }