public void LoadMappedItemsSchemaLogicalnameNotinAttributeMetaData()
        {
            var attributeMetaDataItem = new AttributeMetadata
            {
                LogicalName = "contactattnoattributes1"
            };

            var attributes = new List <AttributeMetadata>
            {
                attributeMetaDataItem
            };

            var entityMetadata = new EntityMetadata();
            var field          = entityMetadata.GetType().GetRuntimeFields().First(a => a.Name == "_attributes");

            field.SetValue(entityMetadata, attributes.ToArray());

            metadataServiceMock.Setup(x => x.RetrieveEntities(It.IsAny <string>(), It.IsAny <IOrganizationService>(), It.IsAny <IExceptionService>()))
            .Returns(entityMetadata)
            .Verifiable();

            using (var systemUnderTest = new MappingListLookup(mappings, orgServiceMock.Object, metadata, selectedValue, metadataServiceMock.Object, dataMigratorExceptionHelperMock.Object))
            {
                FluentActions.Invoking(() => systemUnderTest.LoadMappedItems())
                .Should()
                .Throw <MappingException>();
            }

            metadataServiceMock.VerifyAll();
        }
示例#2
0
 public void OpenMappingForm(ServiceParameters serviceParameters, IWin32Window owner, List <EntityMetadata> inputCachedMetadata, Dictionary <string, Dictionary <string, List <string> > > inputLookupMaping, string inputEntityLogicalName)
 {
     using (var mappingDialog = new MappingListLookup(inputLookupMaping, serviceParameters.OrganizationService, inputCachedMetadata, inputEntityLogicalName, serviceParameters.MetadataService, serviceParameters.ExceptionService)
     {
         StartPosition = FormStartPosition.CenterParent
     })
     {
         if (owner != null)
         {
             mappingDialog.ShowDialog(owner);
         }
         mappingDialog.RefreshMappingList();
     }
 }
        public void ValidateLookupColumnLookupAttributeMetadata()
        {
            string entityName = "contactattnoattributes";

            mappings = new Dictionary <string, Dictionary <string, List <string> > >();
            var values = new Dictionary <string, List <string> >
            {
                { entityName, new List <string>()
                  {
                      entityName
                  } }
            };

            mappings.Add(entityName, values);

            var attributeMetaDataItem = new LookupAttributeMetadata
            {
                LogicalName = entityName
            };

            attributeMetaDataItem.Targets = new List <string> {
                entityName
            }.ToArray();

            var attributes = new List <AttributeMetadata>
            {
                attributeMetaDataItem
            };

            var entityMetadata  = new EntityMetadata();
            var attributesField = entityMetadata.GetType().GetRuntimeFields().First(a => a.Name == "_attributes");

            attributesField.SetValue(entityMetadata, attributes.ToArray());

            metadataServiceMock.Setup(x => x.RetrieveEntities(It.IsAny <string>(), It.IsAny <IOrganizationService>(), It.IsAny <IExceptionService>()))
            .Returns(entityMetadata)
            .Verifiable();

            int rowIndex = 0;

            using (var systemUnderTest = new MappingListLookup(mappings, orgServiceMock.Object, metadata, selectedValue, metadataServiceMock.Object, dataMigratorExceptionHelperMock.Object))
            {
                FluentActions.Invoking(() => systemUnderTest.ValidateLookupColumn(rowIndex, entityName, attributes.ToArray()))
                .Should()
                .NotThrow();
            }

            metadataServiceMock.Verify(x => x.RetrieveEntities(It.IsAny <string>(), It.IsAny <IOrganizationService>(), It.IsAny <IExceptionService>()), Times.Exactly(1));
        }
        public void LoadMappedItemsOwnerAttributeTypeCode()
        {
            string entityName = "contactattnoattributes";

            selectedValue = "contactattnoattributes1";

            mappings = new Dictionary <string, Dictionary <string, List <string> > >();
            var values = new Dictionary <string, List <string> >
            {
                { selectedValue, new List <string>()
                  {
                      entityName
                  } }
            };

            mappings.Add(selectedValue, values);

            var attributeMetaDataItem = new AttributeMetadata
            {
                LogicalName = selectedValue
            };
            var attributeTypeField = attributeMetaDataItem.GetType().GetRuntimeFields().First(a => a.Name == "_attributeType");

            attributeTypeField.SetValue(attributeMetaDataItem, AttributeTypeCode.Owner);

            var attributes = new List <AttributeMetadata>
            {
                attributeMetaDataItem
            };

            var entityMetadata  = new EntityMetadata();
            var attributesField = entityMetadata.GetType().GetRuntimeFields().First(a => a.Name == "_attributes");

            attributesField.SetValue(entityMetadata, attributes.ToArray());

            metadataServiceMock.Setup(x => x.RetrieveEntities(It.IsAny <string>(), It.IsAny <IOrganizationService>(), It.IsAny <IExceptionService>()))
            .Returns(entityMetadata)
            .Verifiable();

            using (var systemUnderTest = new MappingListLookup(mappings, orgServiceMock.Object, metadata, selectedValue, metadataServiceMock.Object, dataMigratorExceptionHelperMock.Object))
            {
                FluentActions.Invoking(() => systemUnderTest.LoadMappedItems())
                .Should()
                .NotThrow();
            }

            metadataServiceMock.Verify(x => x.RetrieveEntities(It.IsAny <string>(), It.IsAny <IOrganizationService>(), It.IsAny <IExceptionService>()), Times.Exactly(2));
        }