Ejemplo n.º 1
0
        public void FlowcontrolTest_WithBFCreateCopy()
        {
            //Arrange
            BusinessFlow bf = new BusinessFlow("Test");

            Activity activity = new Activity();

            activity.ActivityName = "Login";

            ActGotoURL actGotoURL = new ActGotoURL();

            actGotoURL.Description = "Launch";

            activity.Acts.Add(actGotoURL);

            Activity activity2 = new Activity();

            activity2.ActivityName = "Test";

            ActDummy act2 = new ActDummy();

            act2.Description = "WaitForApp";

            activity.Acts.Add(act2);

            FlowControl flowControl = new FlowControl();

            flowControl.Active            = true;
            flowControl.Condition         = "1=1";
            flowControl.FlowControlAction = eFlowControlAction.GoToActivity;
            flowControl.Value             = activity2.Guid + flowControl.GUID_NAME_SEPERATOR + activity2.ItemName;

            FlowControl flowControl2 = new FlowControl();

            flowControl2.Active            = true;
            flowControl2.Condition         = "2=2";
            flowControl2.FlowControlAction = eFlowControlAction.GoToAction;
            flowControl2.Value             = act2.Guid + flowControl.GUID_NAME_SEPERATOR + act2.ItemName;


            actGotoURL.FlowControls.Add(flowControl);
            actGotoURL.FlowControls.Add(flowControl2);

            bf.Activities.RemoveAt(0);
            bf.Activities.Add(activity);
            bf.Activities.Add(activity2);

            activity2.ActivityName = "Test_New";
            bf.RepositorySerializer.SaveToFile(bf, TestResources.GetTempFile("BF.xml"));

            //Act
            BusinessFlow bfCopy = (BusinessFlow)bf.CreateInstance();

            Guid newGuidOfActivity2 = bfCopy.Activities.Where(x => x.ItemName == "Test_New").FirstOrDefault().Guid;

            Guid newGuidOfAct2 = bfCopy.Activities[0].Acts.Where(x => x.ItemName == "WaitForApp").FirstOrDefault().Guid;


            //Assert
            Assert.AreEqual(bfCopy.Activities[0].Acts[0].FlowControls[1].GetGuidFromValue(), newGuidOfAct2);
            Assert.AreEqual(bfCopy.Activities[0].Acts[0].FlowControls[0].GetGuidFromValue(), newGuidOfActivity2);
        }
Ejemplo n.º 2
0
        public void ActivityVariableDependancyTest_WithCreateInstance()
        {
            //Arrange
            BusinessFlow bf = new BusinessFlow("Test");

            Activity activity = new Activity();
            VariableSelectionList selectionList2 = new VariableSelectionList();

            selectionList2.Name = "activityVariable1";
            selectionList2.OptionalValuesList.Add(new OptionalValue("c"));
            selectionList2.OptionalValuesList.Add(new OptionalValue("d"));

            VariableDependency vd = new VariableDependency(selectionList2.Guid, selectionList2.ItemName, selectionList2.Value);

            ActGotoURL actGotoURL = new ActGotoURL();

            actGotoURL.Description = "www.google.com";
            actGotoURL.VariablesDependencies.Add(vd);
            ActDummy actDummy = new ActDummy();

            actDummy.Description = "www.google.com";
            actDummy.VariablesDependencies.Add(vd);
            activity.Variables.Add(selectionList2);
            activity.Acts.Add(actGotoURL);
            activity.Acts.Add(actDummy);
            Activity activity2 = new Activity();
            ActDummy act2      = new ActDummy();

            act2.Description = "www.google.com";
            activity2.Acts.Add(act2);
            VariableSelectionList selectionList = new VariableSelectionList();

            selectionList.Name = "bfVariable1";
            selectionList.OptionalValuesList.Add(new OptionalValue("a"));
            selectionList.OptionalValuesList.Add(new OptionalValue("b"));

            bf.Variables.Add(selectionList);


            VariableDependency vd1 = new VariableDependency(selectionList.Guid, selectionList.ItemName, selectionList.Value);

            activity.VariablesDependencies.Add(vd1);
            activity2.VariablesDependencies.Add(vd1);

            bf.Activities.RemoveAt(0);
            bf.Activities.Add(activity);
            bf.Activities.Add(activity2);


            //Act
            BusinessFlow bfCopy = (BusinessFlow)bf.CreateInstance();

            Guid newBFVarGuid       = bfCopy.Variables.Where(x => x.Name == "bfVariable1").FirstOrDefault().Guid;
            Guid newActivityVarGuid = bfCopy.Activities[0].Variables[0].Guid;

            //Assert
            Assert.AreEqual(newBFVarGuid, bfCopy.Activities[0].VariablesDependencies[0].VariableGuid);
            Assert.AreEqual(newBFVarGuid, bfCopy.Activities[1].VariablesDependencies[0].VariableGuid);
            Assert.AreEqual(newActivityVarGuid, bfCopy.Activities[0].Acts[0].VariablesDependencies[0].VariableGuid);
            Assert.AreEqual(newActivityVarGuid, bfCopy.Activities[0].Acts[1].VariablesDependencies[0].VariableGuid);
        }