Ejemplo n.º 1
0
        public void StoreLookUpAttributeWithLookupAttributeMetadataButEmptyTargetList()
        {
            var    attributeLogicalName = "contactId";
            string primaryAttribute     = "contactId";
            var    crmField             = new Capgemini.Xrm.DataMigration.Model.CrmField()
            {
                PrimaryKey = false,
                FieldName  = primaryAttribute,
                FieldType  = "entityreference"
            };

            var attribute = new LookupAttributeMetadata
            {
                LogicalName = attributeLogicalName,
                DisplayName = new Label
                {
                    UserLocalizedLabel = new LocalizedLabel {
                        Label = attributeLogicalName
                    }
                }
            };

            NotificationServiceMock.Setup(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"))
            .Verifiable();

            FluentActions.Invoking(() => systemUnderTest.StoreLookUpAttribute(attribute, crmField, NotificationServiceMock.Object))
            .Should()
            .NotThrow();

            NotificationServiceMock.Verify(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"), Times.Never);
            crmField.LookupType.Should().BeNull();
        }
Ejemplo n.º 2
0
        public void StoreAttributePrimaryKeyWithWrongPrimaryAttributeName()
        {
            string primaryAttribute = "contactId";
            var    crmField         = new Capgemini.Xrm.DataMigration.Model.CrmField()
            {
                PrimaryKey = false, FieldName = "contactId2"
            };

            FluentActions.Invoking(() => systemUnderTest.StoreAttributePrimaryKey(primaryAttribute, crmField))
            .Should()
            .NotThrow();

            crmField.PrimaryKey.Should().BeFalse();
        }
Ejemplo n.º 3
0
        public void StoreLookUpAttributeLookupAttributeMetadataIsNull()
        {
            string primaryAttribute = "contactId";
            var    crmField         = new Capgemini.Xrm.DataMigration.Model.CrmField()
            {
                PrimaryKey = false,
                FieldName  = primaryAttribute,
                FieldType  = "entityreference"
            };

            NotificationServiceMock.Setup(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"))
            .Verifiable();

            FluentActions.Invoking(() => systemUnderTest.StoreLookUpAttribute(null, crmField, NotificationServiceMock.Object))
            .Should()
            .NotThrow();

            NotificationServiceMock.Verify(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"), Times.Once);
        }
Ejemplo n.º 4
0
        public void StoreLookUpAttributeNotLookupAttributeMetadata()
        {
            var    attributeLogicalName = "contactId";
            string primaryAttribute     = "contactId";
            var    crmField             = new Capgemini.Xrm.DataMigration.Model.CrmField()
            {
                PrimaryKey = false,
                FieldName  = primaryAttribute,
                FieldType  = "entityreference"
            };

            var attribute = new AttributeMetadata
            {
                LogicalName = attributeLogicalName,
                DisplayName = new Label
                {
                    UserLocalizedLabel = new LocalizedLabel {
                        Label = attributeLogicalName
                    }
                }
            };

            var attributeTypeName = attribute.GetType().GetRuntimeFields().First(a => a.Name == "_attributeTypeDisplayName");

            attributeTypeName.SetValue(attribute, new AttributeTypeDisplayName {
                Value = attributeLogicalName
            });

            NotificationServiceMock.Setup(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"))
            .Verifiable();

            FluentActions.Invoking(() => systemUnderTest.StoreLookUpAttribute(attribute, crmField, NotificationServiceMock.Object))
            .Should()
            .NotThrow();

            NotificationServiceMock.Verify(x => x.DisplayFeedback("The supplied attribute is null. Expecting an Entity Reference!"), Times.Once);
        }