public void FlowDecision_GetDifferences_WhenFlowArmsModifiedOnBithSides_DecisionToolHasNoConflict()
        {
            var activityParser = new ActivityParser();
            var shellView      = new Mock <IShellViewModel>();
            var serverMock     = new Mock <IServer>();

            shellView.Setup(model => model.ActiveServer).Returns(serverMock.Object);
            CustomContainer.Register(shellView.Object);
            CustomContainer.Register <IActivityParser>(activityParser);
            var bb                = new DsfFlowDecisionActivity();
            var jsonSerializer    = new Dev2JsonSerializer();
            var dev2DecisionStack = new Dev2DecisionStack
            {
                TheStack = new List <Dev2Decision>
                {
                    new Dev2Decision
                    {
                        Cols1 = new List <DataStorage.WarewolfAtom>
                        {
                            DataStorage.WarewolfAtom.NewDataString("a")
                        }
                    },
                    new Dev2Decision
                    {
                        Cols1 = new List <DataStorage.WarewolfAtom>
                        {
                            DataStorage.WarewolfAtom.NewDataString("a")
                        }
                    }
                },
                DisplayText  = "a",
                FalseArmText = "ErrorArm",
                TrueArmText  = "true Arm",
                Version      = "2",
                Mode         = Dev2DecisionMode.AND
            };

            bb.ExpressionText = jsonSerializer.Serialize(dev2DecisionStack);

            var assignId = Guid.NewGuid().ToString();
            var chart    = new Flowchart
            {
                StartNode = new FlowStep
                {
                    Action = new DsfMultiAssignActivity
                    {
                        FieldsCollection = new List <ActivityDTO>
                        {
                            new ActivityDTO("field1", "field1", 1),
                            new ActivityDTO("field2", "field2", 4),
                            new ActivityDTO("field3", "field3", 3),
                            new ActivityDTO("field3", "field3", 2),
                        },
                        UniqueID = assignId
                    },
                    Next = new FlowDecision
                    {
                        DisplayName = "DisplayName",
                        True        = new FlowStep
                        {
                            Action = ActivityBuilderFactory.BuildActivity(typeof(DsfCalculateActivity)),
                            Next   = new FlowStep
                            {
                                Action = ActivityBuilderFactory.BuildActivity(typeof(DsfBaseConvertActivity))
                            }
                        },
                        Condition = bb
                    }
                }
            };

            var otherChart = new Flowchart
            {
                StartNode = new FlowStep
                {
                    Action = new DsfMultiAssignActivity
                    {
                        FieldsCollection = new List <ActivityDTO>
                        {
                            new ActivityDTO("field1", "field1", 1),
                            new ActivityDTO("field2", "field2", 2),
                            new ActivityDTO("field2", "fff", 4),
                            new ActivityDTO("field3", "field3", 3),
                        },
                        UniqueID = assignId
                    },
                    Next = new FlowDecision
                    {
                        DisplayName = "DisplayName",
                        True        = new FlowStep
                        {
                            Action = ActivityBuilderFactory.BuildActivity(typeof(DsfCalculateActivity)),
                            Next   = new FlowStep
                            {
                                Action = ActivityBuilderFactory.BuildActivity(typeof(DsfBaseConvertActivity))
                            }
                        },
                        Condition = bb
                    }
                }
            };

            var current = ParserTestHelper.CreateContextualResourceModel(otherChart);
            var diff    = ParserTestHelper.CreateContextualResourceModel(chart);

            var psd = new ServiceDifferenceParser();

            var(currentTree, diffTree) = psd.GetDifferences(current, diff);

            var currConflicts = currentTree;
            var diffConflicts = diffTree;

            var count = currConflicts.Count + diffConflicts.Count;

            Assert.AreEqual(8, count);
            Assert.IsFalse(diffTree.First().IsInConflict);
            Assert.IsFalse(currentTree.First().IsInConflict);
            Assert.IsFalse(diffTree.Last().IsInConflict);
            Assert.IsFalse(currentTree.Last().IsInConflict);
            Assert.AreEqual(assignId, diffTree[0].UniqueId);
            Assert.AreEqual(assignId, currentTree[0].UniqueId);

            //First Node chart
            var tupleDifference = diffTree[0];
            var tupleCurrent    = currentTree[0];

            Assert.IsNotNull(tupleDifference);
            Assert.IsNotNull(tupleCurrent);

            var devActivityDiff = tupleDifference.Activity;
            var devActivityCurr = tupleCurrent.Activity;

            Assert.IsNotNull(devActivityDiff);
            Assert.IsNotNull(devActivityCurr);
            Assert.AreEqual(assignId, devActivityCurr.UniqueID);
            Assert.AreEqual(assignId, devActivityDiff.UniqueID);

            //Decision Node chart
            var tupleDifference1 = diffTree[1];
            var tupleCurrent1    = currentTree[1];

            Assert.IsNotNull(tupleDifference1);
            Assert.IsNotNull(tupleCurrent1);

            var devActivityDiff1 = tupleDifference1.Activity;
            var devActivityCurr1 = tupleCurrent1.Activity;

            Assert.IsNotNull(devActivityDiff1);
            Assert.IsNotNull(devActivityCurr1);
            Assert.IsTrue(devActivityDiff1.Equals(devActivityCurr1));
        }
        public void FlowSwitch_GetDifferences_WhenCasesTheSame_SwitchHasNoConflict()
        {
            var activityParser = new ActivityParser();
            var shellView      = new Mock <IShellViewModel>();
            var serverMock     = new Mock <IServer>();

            shellView.Setup(model => model.ActiveServer).Returns(serverMock.Object);
            CustomContainer.Register(shellView.Object);
            CustomContainer.Register <IActivityParser>(activityParser);
            var switchActivity = new DsfFlowSwitchActivity("MyName", new Mock <IDebugDispatcher>().Object, It.IsAny <bool>())
            {
                UniqueID = Guid.NewGuid().ToString(),
            };
            var dev2DecisionStack = new Dev2DecisionStack
            {
                TheStack = new List <Dev2Decision>
                {
                    new Dev2Decision
                    {
                        Cols1 = new List <DataStorage.WarewolfAtom>
                        {
                            DataStorage.WarewolfAtom.NewDataString("a")
                        }
                    },
                    new Dev2Decision
                    {
                        Cols1 = new List <DataStorage.WarewolfAtom>
                        {
                            DataStorage.WarewolfAtom.NewDataString("a")
                        }
                    }
                },
                DisplayText  = "a",
                FalseArmText = "ErrorArm",
                TrueArmText  = "true Arm",
                Version      = "2",
                Mode         = Dev2DecisionMode.AND,
            };
            var jsonSerializer = new Dev2JsonSerializer();

            switchActivity.ExpressionText = jsonSerializer.Serialize(dev2DecisionStack);
            var assignId = Guid.NewGuid().ToString();
            var chart    = new Flowchart
            {
                StartNode = new FlowStep
                {
                    Action = new DsfMultiAssignActivity
                    {
                        FieldsCollection = new List <ActivityDTO>
                        {
                            new ActivityDTO("field1", "field1", 1),
                            new ActivityDTO("field2", "field2", 4),
                            new ActivityDTO("field3", "field3", 3),
                            new ActivityDTO("field3", "field3", 2),
                        },
                        UniqueID = assignId
                    },
                    Next = new FlowSwitch <string>
                    {
                        DisplayName = "DisplayName",
                        Default     = new FlowStep
                        {
                            Action = ActivityBuilderFactory.BuildActivity(typeof(DsfCalculateActivity))
                        },
                        Expression = switchActivity
                    }
                }
            };

            var otherChart = new Flowchart
            {
                StartNode = new FlowStep
                {
                    Action = new DsfMultiAssignActivity
                    {
                        FieldsCollection = new List <ActivityDTO>
                        {
                            new ActivityDTO("field1", "field1", 1),
                            new ActivityDTO("field2", "field2", 2),
                            new ActivityDTO("field2", "fff", 4),
                            new ActivityDTO("field3", "field3", 3),
                        },
                        UniqueID = assignId
                    },
                    Next = new FlowSwitch <string>
                    {
                        DisplayName = "DisplayName",
                        Default     = new FlowStep
                        {
                            Action = ActivityBuilderFactory.BuildActivity(typeof(DsfCalculateActivity))
                        },
                        Expression = switchActivity
                    }
                }
            };

            var current = ParserTestHelper.CreateContextualResourceModel(otherChart);
            var diff    = ParserTestHelper.CreateContextualResourceModel(chart);

            var psd = new ServiceDifferenceParser();

            var(currentTree, diffTree) = psd.GetDifferences(current, diff);

            var currConflicts = currentTree;
            var diffConflicts = diffTree;

            var count = currConflicts.Count + diffConflicts.Count;

            Assert.AreEqual(6, count);

            Assert.IsFalse(diffTree.First().IsInConflict);
            Assert.IsFalse(currentTree.First().IsInConflict);

            Assert.IsFalse(diffTree.Last().IsInConflict);
            Assert.IsFalse(currentTree.Last().IsInConflict);

            Assert.AreEqual(assignId, diffTree[0].UniqueId);
            Assert.AreEqual(assignId, currentTree[0].UniqueId);
        }