public void ConvertShouldReturnNullIfValueIsNotProcessViewFieldViewModel()
        {
            var converter = new ProcessViewFieldCustomConfigEditorConverter { IsInitialized = true };

            Assert.IsNull(converter.Convert(new object(), null, null, null));
            Assert.IsNull(converter.Convert(null, null, null, null));
        }
        public void ConvertShouldReturnNullIfFieldIsNull()
        {
            var converter = new ProcessViewFieldCustomConfigEditorConverter { IsInitialized = true };

            var vm = new ProcessViewFieldViewModel(null, null);
            
            Assert.IsNull(converter.Convert(vm, null, null, null));
        }
        public void ConvertShouldReturnNullIfTemplateFieldIsNotFound()
        {
            var converter = new ProcessViewFieldCustomConfigEditorConverter
                                {
                                    IsInitialized = true,
                                    ProcessViewManager = new ProcessViewManager
                                    {
                                        ProcessViewsFactory = new[]
                                        {
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => new DataCollectProcessViewTemplate(), null), 
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => new APQPProcessViewTemplate(), null), 
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => new DocumentProcessViewTemplate(), null), 
                                        }
                                    }
                                };

            var vm = new ProcessViewFieldViewModel(new ProcessViewFieldEdit { TemplateFieldGuid = Guid.Empty }, null);

            Assert.IsNull(converter.Convert(vm, null, null, null));
        }
        public void ConvertShouldReturnNullIfTemplateFieldCustomConfiguratorIsNull()
        {
            var dataCollectionTemplate = new DataCollectProcessViewTemplate();
            var converter = new ProcessViewFieldCustomConfigEditorConverter
            {
                IsInitialized = true,
                ProcessViewManager = new ProcessViewManager
                {
                    ProcessViewsFactory = new[]
                                        {
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => dataCollectionTemplate, null), 
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => new APQPProcessViewTemplate(), null), 
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => new DocumentProcessViewTemplate(), null), 
                                        }
                }
            };

            var checkListField = dataCollectionTemplate.Sections.SelectMany(s => s.Fields).FirstOrDefault(f => f.Guid == DataCollectProcessViewTemplate.ChecklistFieldGuid);
            Mock.Arrange(() => checkListField.CustomConfigurator).Returns((IProcessViewFieldCustomConfigurator)null);

            var vm = new ProcessViewFieldViewModel(new ProcessViewFieldEdit { TemplateFieldGuid = DataCollectProcessViewTemplate.ChecklistFieldGuid }, null);

            Assert.IsNull(converter.Convert(vm, null, null, null));
        }
        public void ConvertShouldReturnTemplateFieldCustomConfigurator()
        {
            var dataCollectionTemplate = new DataCollectProcessViewTemplate();
            var converter = new ProcessViewFieldCustomConfigEditorConverter
            {
                IsInitialized = true,
                ProcessViewManager = new ProcessViewManager
                {
                    ProcessViewsFactory = new[]
                                        {
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => dataCollectionTemplate, null), 
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => new APQPProcessViewTemplate(), null), 
                                            new Lazy<IProcessViewTemplate, IExportAsProcessViewTemplateAttributeMetadata>(() => new DocumentProcessViewTemplate(), null), 
                                        }
                },
                FieldConfigurators = new[]
                                         {
                                             new Lazy<IProcessViewFieldCustomConfigViewModel, IExportAsProcessViewFieldCustomConfigViewModelAttributeMetadata>(Mock.Create<IProcessViewFieldCustomConfigViewModel>, new ExportAsProcessViewFieldCustomConfigViewModelAttribute(typeof(DataCollectProcessViewChecklistFieldConfigurator))), 
                                         }
            };

            var vm = new ProcessViewFieldViewModel(new ProcessViewFieldEdit { TemplateFieldGuid = DataCollectProcessViewTemplate.ChecklistFieldGuid }, null);

            Assert.IsNotNull(converter.Convert(vm, null, null, null));
        }