private static bool NeedsIndexesOnSubfields(FieldInfo field)
        {
            switch (field.ColumnType)
            {
                case ColumnTypes.Reference:
                case ColumnTypes.MultiReference:
                    return true;

                default:
                    return false;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProcessFieldInfoWrapper"/> class.
 /// </summary>
 /// <param name="field">The field.</param>
 public ProcessFieldInfoWrapper(FieldInfo field)
 {
     _field = field;
 }
        private static PublishedProcessInfo GetReferencedProcess(FieldInfo field)
        {
            switch (field.ColumnType)
            {
                case ColumnTypes.Reference:
                case ColumnTypes.MultiReference:
                    {
                        var fieldInfo = CrossRefFieldInfo.GetCrossRefFieldInfo(field.Id);

                        return fieldInfo != null && fieldInfo.CrossRefProcessId > 0
                                   ? PublishedProcesses.GetPublishedProcessInfo(fieldInfo.CrossRefProcessId)
                                   : null;
                    }

                case ColumnTypes.Checklist:
                    {
                        var fieldInfo = ChecklistFieldInfo.GetChecklistFieldInfo(field.Id);

                        return fieldInfo != null && fieldInfo.CrossRefProcessId > 0
                                   ? PublishedProcesses.GetPublishedProcessInfo(fieldInfo.CrossRefProcessId)
                                   : null;
                    }
            }

            return null;
        }
        public void CrossReferenceSubfieldsRetrieverCanLoadCrossReferenceSubfields()
        {
            // Arrange.
            var process = new PublishedProcessInfo();
            var crField = new FieldInfo(1, "CR Field", "CRField_f", null, "TestProcess_p", ColumnTypes.Reference, Guid.Empty, false, false, false);
            var field1 = new FieldInfo();
            var field2 = new FieldInfo();
            var field3 = new FieldInfo();
            var fieldList = new FieldListStub(field1, field2, field3);
            var processRetriever = Mock.Create<PublishedProcessFieldsRetriever>(Behavior.Loose);
            Mock.Arrange(() => processRetriever.Process).Returns(process);
            Mock.Arrange(() => processRetriever.Fields).Returns(fieldList);
            Mock.Arrange(() => PublishedProcessFieldsRetriever.GetProcessByCrossReferenceFieldAsync("TestProcess_p", "CRField_f", true))
                .Returns(TaskEx.FromResult(processRetriever));

            var expressionField1 = Mock.Create<IExpressionField>(Behavior.Loose);
            var expressionField2 = Mock.Create<IExpressionField>(Behavior.Loose);

            var fieldMap = new Dictionary<FieldInfo, IExpressionField>();
            fieldMap[field1] = expressionField1;
            fieldMap[field2] = expressionField2;

            var retriever = new ExpressionDesignerWindowViewModelBase.CrossReferenceSubfieldsRetriever(crField, fieldMap.ContainsKey, (f, p, o) => fieldMap[f]);
            var sourceField = Mock.Create<IExpressionField>(Behavior.Loose);
            var connector = Mock.Create<IConnector>(Behavior.Loose);
            Mock.Arrange(() => sourceField.Connector).Returns(connector);
            var owner = Mock.Create<ExpressionObjectBase>(Behavior.CallOriginal);
            Mock.Arrange(() => connector.Owner).Returns(owner);

            IExpressionField[] subfields = null;

            // Act.
            retriever.BeginLoad(sourceField, (sf, fields) => subfields = fields.ToArray());

            // Assert.
            Assert.IsNotNull(subfields);
            Assert.AreEqual(2, subfields.Length);
            Assert.IsTrue(subfields.Contains(expressionField1));
            Assert.IsTrue(subfields.Contains(expressionField2));
        }