コード例 #1
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);
        }
コード例 #2
0
        public void ConflictModelFactory_GivenDsfSwitchConflictNode_ShouldReturnMergeToolModel()
        {
            //------------Setup for test--------------------------
            var adapter = new Mock <IApplicationAdaptor>();

            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 dev2DecisionStack  = new Dev2DecisionStack
            {
                TheStack     = new List <Dev2Decision>(),
                TrueArmText  = "a",
                FalseArmText = "a",
                DisplayText  = "a",
                Mode         = Dev2DecisionMode.AND
            };
            var serializer = new Dev2JsonSerializer();
            var serialize  = serializer.Serialize(dev2DecisionStack);
            var condition  = new DsfFlowSwitchActivity
            {
                ExpressionText = serialize
            };
            var value = new DsfSwitch(condition)
            {
                Switch   = "bbb",
                Switches = new Dictionary <string, IDev2Activity>
                {
                    { "a", new DsfCalculateActivity() },
                    { "b", new DsfCalculateActivity() }
                }
            };
            var assignStep = new FlowStep
            {
                Action = value
            };

            node.Setup(p => p.Activity).Returns(value);
            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);
            var mergeToolModel = completeConflict.CreateModelItem(toolConflictItem, node.Object);

            Assert.AreEqual("bbb", mergeToolModel.MergeDescription);
            Assert.AreEqual(typeof(SwitchDesignerViewModel).FullName, ((ToolConflictItem)mergeToolModel).ActivityDesignerViewModel.GetType().FullName);
        }
コード例 #3
0
        public void ConflictModelFactory_GivenNullConflictNodeActivity_ShouldReturnNull()
        {
            //------------Setup for test--------------------------
            var adapter = new Mock<IApplicationAdaptor>();
            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>();

            node.Setup(p => p.Activity).Returns(new DsfCalculateActivity());
            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-------------------------
            var mergeToolModel = completeConflict.CreateModelItem(toolConflictItem, node.Object);
            Assert.IsNotNull(mergeToolModel);
        }