Example #1
0
        public void CollectCrmEntityFields()
        {
            var entityLogicalName = "contact";

            inputCheckedEntity.Add(entityLogicalName);
            var attributeSet = new HashSet <string>()
            {
                "contactId", "firstname", "lastname"
            };

            inputEntityAttributes.Add(entityLogicalName, attributeSet);
            var inputAttributeMapping = new AttributeTypeMapping();

            var schemaConfiguration = new Capgemini.Xrm.DataMigration.Config.CrmSchemaConfiguration();

            var entityMetadata = InstantiateEntityMetaData(entityLogicalName);

            InsertAttributeList(entityMetadata, new List <string> {
                "contactId", "firstname", "lastname"
            });

            var serviceParameters = GenerateMigratorParameters();

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

            FluentActions.Invoking(() => systemUnderTest.CollectCrmEntityFields(inputCheckedEntity, schemaConfiguration, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, serviceParameters))
            .Should()
            .NotThrow();

            MetadataServiceMock.VerifyAll();
        }
Example #2
0
        public void AreCrmEntityFieldsSelected()
        {
            var entityLogicalName = "contact";

            inputCheckedEntity.Add(entityLogicalName);
            var entityMetadata = InstantiateEntityMetaData(entityLogicalName);

            InsertAttributeList(entityMetadata, new List <string> {
                "contactId", "firstname", "lastname"
            });

            var attributeSet = new HashSet <string>()
            {
                "contactId", "firstname", "lastname"
            };

            inputEntityAttributes.Add(entityLogicalName, attributeSet);
            var inputAttributeMapping = new AttributeTypeMapping();
            var serviceParameters     = GenerateMigratorParameters();

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

            var actual = systemUnderTest.AreCrmEntityFieldsSelected(inputCheckedEntity, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, serviceParameters);

            actual.Should().BeTrue();
            MetadataServiceMock.VerifyAll();
        }
        public void GetAttributeList()
        {
            string entityLogicalName = "contact";

            AttributeMetadata[] attributes = null;
            var  entityMetadata            = new EntityMetadata();
            bool showSystemAttributes      = true;
            var  serviceParameters         = GenerateMigratorParameters();

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

            attributes = systemUnderTest.GetAttributeList(entityLogicalName, showSystemAttributes, serviceParameters);

            attributes.Should().BeNull();
        }
Example #4
0
        public void PopulateRelationshipActionNoManyToManyRelationships()
        {
            string entityLogicalName = "contact";
            var    entityMetadata    = new EntityMetadata();

            var migratorServiceParameters = GenerateMigratorParameters();

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

            var actual = systemUnderTest.PopulateRelationshipAction(entityLogicalName, inputEntityRelationships, migratorServiceParameters);

            actual.Count.Should().Be(0);

            ServiceMock.VerifyAll();
            MetadataServiceMock.VerifyAll();
        }
Example #5
0
        public void PopulateRelationshipAction()
        {
            string entityLogicalName = "account_contact";
            var    items             = new List <System.Windows.Forms.ListViewItem>
            {
                new System.Windows.Forms.ListViewItem("Item1"),
                new System.Windows.Forms.ListViewItem("Item2")
            };

            var entityMetadata = new EntityMetadata();

            var relationship = new ManyToManyRelationshipMetadata
            {
                Entity1LogicalName        = "account",
                Entity1IntersectAttribute = "accountid",
                IntersectEntityName       = "account_contact",
                Entity2LogicalName        = "contact",
                Entity2IntersectAttribute = "contactid"
            };

            InsertManyToManyRelationshipMetadata(entityMetadata, relationship);

            var migratorServiceParameters = GenerateMigratorParameters();

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

            using (var listView = new System.Windows.Forms.ListView())
            {
                var controller = new EntityController();
                controller.PopulateEntitiesListView(items, null, null, listView, NotificationServiceMock.Object);

                var actual = systemUnderTest.PopulateRelationshipAction(entityLogicalName, inputEntityRelationships, migratorServiceParameters);

                actual.Count.Should().BeGreaterThan(0);
            }

            ServiceMock.VerifyAll();
            MetadataServiceMock.VerifyAll();
        }
        protected void SetupMockObjects(string entityLogicalName)
        {
            var entityMetadata = InstantiateEntityMetaData(entityLogicalName);

            InsertAttributeList(entityMetadata, new List <string> {
                "contactattnoentity1"
            });

            var metadataList = new List <EntityMetadata>
            {
                entityMetadata
            };

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

            MetadataServiceMock.Setup(x => x.RetrieveEntities(It.IsAny <IOrganizationService>()))
            .Returns(metadataList)
            .Verifiable();
        }
        public void SaveSchemaEntityAttributeSelected()
        {
            NotificationServiceMock.Setup(x => x.DisplayFeedback("Please select at least one attribute for each selected entity!"))
            .Verifiable();
            var entityLogicalName = "contact";
            var entityMetadata    = InstantiateEntityMetaData(entityLogicalName);

            InsertAttributeList(entityMetadata, new List <string> {
                "contactId", "firstname", "lastname"
            });

            inputCheckedEntity.Add(entityLogicalName);

            var attributeSet = new HashSet <string>()
            {
                "contactId", "firstname", "lastname"
            };

            inputEntityAttributes.Add(entityLogicalName, attributeSet);
            var inputAttributeMapping = new AttributeTypeMapping();
            var serviceParameters     = GenerateMigratorParameters();

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

            using (var schemaPathTextBox = new System.Windows.Forms.TextBox())
            {
                var inputCrmSchemaConfiguration = new DataMigration.Config.CrmSchemaConfiguration();

                FluentActions.Invoking(() => systemUnderTest.SaveSchema(serviceParameters, inputCheckedEntity, inputEntityRelationships, inputEntityAttributes, inputAttributeMapping, inputCrmSchemaConfiguration, schemaPathTextBox))
                .Should()
                .NotThrow();
            }

            MetadataServiceMock.VerifyAll();
            NotificationServiceMock.Verify(x => x.DisplayFeedback("Please select at least one attribute for each selected entity!"), Times.Never);
        }