public void GetAttributeDotNetTypeUniqueidentifier()
        {
            string entityName    = "contactadntguid1";
            string attributeName = "contactadntid";

            var attributeMetaDataItem = new AttributeMetadata {
                LogicalName = attributeName
            };

            SetFieldValue(attributeMetaDataItem, "_attributeType", AttributeTypeCode.Uniqueidentifier);

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

            RetrieveEntityResponse response = InjectMetaDataToResponse(new RetrieveEntityResponse(), attributes);

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);

            Type actual = null;

            FluentActions.Invoking(() => actual = systemUnderTest.GetAttributeDotNetType(entityName, attributeName))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
            Assert.AreEqual(typeof(Guid), actual);
        }
        public void GetAttribute()
        {
            string entityName    = "contactatt";
            string attributeName = "contactattid";

            AttributeMetadata attributeMetaDataItem = new AttributeMetadata
            {
                LogicalName = attributeName
            };

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

            RetrieveEntityResponse response = InjectMetaDataToResponse(new RetrieveEntityResponse(), attributes);

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);

            AttributeMetadata actual = null;

            FluentActions.Invoking(() => actual = systemUnderTest.GetAttribute(entityName, attributeName))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();

            actual.LogicalName.Should().Be(attributeName);
        }
        public void GetAttributeDotNetTypeManagedProperty()
        {
            string entityName    = "contactadntManagedProperty";
            string attributeName = "contactadntManagedProperty";

            var attributeMetaDataItem = new AttributeMetadata {
                LogicalName = attributeName
            };

            SetFieldValue(attributeMetaDataItem, "_attributeType", AttributeTypeCode.ManagedProperty);

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

            RetrieveEntityResponse response = InjectMetaDataToResponse(new RetrieveEntityResponse(), attributes);

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);
            Type actual = null;

            FluentActions.Invoking(() => actual = systemUnderTest.GetAttributeDotNetType(entityName, attributeName))
            .Should()
            .Throw <ValidationException>();

            MockOrganizationService.VerifyAll();
        }
Example #4
0
        public void AssociateManyToManyEntity()
        {
            ManyToManyDetails details = new ManyToManyDetails
            {
                Entity1IntersectAttribute = "contactid",
                Entity2IntersectAttribute = "accountid",
                IsManyToMany = true,
                SchemaName   = "accountcontact"
            };

            MockEntityMetadataCache.Setup(a => a.GetManyToManyEntityDetails(It.IsAny <string>()))
            .Returns(details);

            testOrgService.ExecutionResponse = new AssociateResponse();

            systemUnderTest = new EntityRepositorySingle(MockOrganizationService.Object, MockRetryExecutor.Object, MockEntityMetadataCache.Object);

            var response = new UpdateResponse();

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>()))
            .Returns(response);

            FluentActions.Invoking(() => systemUnderTest.AssociateManyToManyEntity(entities))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
        public void GetEntityMetadata()
        {
            string entityName = "contactemd";

            RetrieveEntityResponse response = InjectMetaDataToResponse(new RetrieveEntityResponse());

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);

            FluentActions.Invoking(() => systemUnderTest.GetEntityMetadata(entityName))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
        public void GetOrganizationId()
        {
            WhoAmIResponse response = new WhoAmIResponse();

            systemUnderTest = new EntityRepository(MockOrganizationService.Object, MockRetryExecutor.Object, MockEntityMetadataCache.Object);

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);

            FluentActions.Invoking(() => systemUnderTest.GetOrganizationId())
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
        public void DeleteEntity()
        {
            Guid entityId = Guid.NewGuid();

            systemUnderTest = new EntityRepository(MockOrganizationService.Object, MockRetryExecutor.Object, MockEntityMetadataCache.Object);

            MockOrganizationService.Setup(a => a.Delete(It.IsAny <string>(), It.IsAny <Guid>()));

            FluentActions.Invoking(() => systemUnderTest.DeleteEntity(entityName, entityId))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
Example #8
0
        public void GetAllEntitesMetadata()
        {
            systemUnderTest = new EntityRepositorySingle(MockOrganizationService.Object, MockRetryExecutor.Object, MockEntityMetadataCache.Object, cachingMode);

            RetrieveAllEntitiesResponse response = new RetrieveAllEntitiesResponse();

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>()))
            .Returns(response);

            FluentActions.Invoking(() => systemUnderTest.GetAllEntitesMetadata())
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
        public void GetLookUpEntityNameNoEntityFound()
        {
            string entityName    = "contactluenNoEntityFound";
            string attributeName = "contactluenid";

            var manyToManyRelationships = new List <OneToManyRelationshipMetadata>();

            RetrieveEntityResponse response = InjectMetaDataToResponse(new RetrieveEntityResponse(), null, manyToManyRelationships);

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);

            FluentActions.Invoking(() => systemUnderTest.GetLookUpEntityName(entityName, attributeName))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
Example #10
0
        public void CreateEntities()
        {
            testOrgService.ExecutionResponse = new CreateResponse();

            systemUnderTest = new EntityRepositorySingle(MockOrganizationService.Object, MockRetryExecutor.Object, MockEntityMetadataCache.Object);

            var response = new UpdateResponse();

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>()))
            .Returns(response);

            FluentActions.Invoking(() => systemUnderTest.CreateEntities(entities))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
        public void GetIdAliasKey()
        {
            string entityName    = "contactIdAliasKey";
            string attributeName = "contactIdAliasKeyid";

            var attributeMetaDataItem = new AttributeMetadata {
                LogicalName = attributeName
            };

            SetFieldValue(attributeMetaDataItem, "_attributeType", AttributeTypeCode.Uniqueidentifier);

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

            var oneToManyRelationshipMetadata = new OneToManyRelationshipMetadata
            {
                ReferencingAttribute = attributeName
            };
            var oneToManyRelationships = new List <OneToManyRelationshipMetadata>
            {
                oneToManyRelationshipMetadata
            };

            var entityMetaData = InitializeEntityMetadata(attributes, oneToManyRelationships);

            SetFieldValue(entityMetaData, "_primaryIdAttribute", attributeName);

            var response = InjectMetaDataToResponse(new RetrieveEntityResponse(), entityMetaData);

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);

            string actual = null;

            FluentActions.Invoking(() => actual = systemUnderTest.GetIdAliasKey(entityName))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
            actual.Should().NotBeNullOrEmpty();
        }
Example #12
0
        public void Setup()
        {
            InitializeProperties();

            originalEntity = new EntityWrapper(new Entity()
            {
                LogicalName = "testentity", Id = Guid.NewGuid()
            });
            newEntity = new EntityWrapper(new Entity()
            {
                LogicalName = "testentity", Id = Guid.NewGuid()
            });
            updatedEntity = new EntityWrapper(new Entity()
            {
                LogicalName = "testentity", Id = originalEntity.Id
            });
            unchangedEntity = new EntityWrapper(new Entity()
            {
                LogicalName = "testentity", Id = originalEntity.Id
            });

            originalEntity.OriginalEntity.Attributes["testattribute"]  = "1";
            newEntity.OriginalEntity.Attributes["testattribute"]       = "2";
            updatedEntity.OriginalEntity.Attributes["testattribute"]   = "3";
            unchangedEntity.OriginalEntity.Attributes["testattribute"] = originalEntity.OriginalEntity.Attributes["testattribute"];

            var entityCollection = new EntityCollection();

            entityCollection.Entities.Add(originalEntity.OriginalEntity);

            MockEntityRepo.Setup(a => a.GetCurrentOrgService).Returns(MockOrganizationService.Object);

            MockOrganizationService.Setup(a => a.RetrieveMultiple(It.IsAny <QueryBase>()))
            .Returns(entityCollection);

            systemUnderTest = new SkipExistingRecordProcessor(MockLogger.Object, MockEntityRepo.Object);
        }
        public void GetManyToManyEntityDetails()
        {
            string intersectEntityName = "accountcontactmtmed";

            var relationship = new ManyToManyRelationshipMetadata
            {
                IntersectEntityName = intersectEntityName
            };

            var manyToManyRelationships = new List <ManyToManyRelationshipMetadata>
            {
                relationship
            };

            RetrieveEntityResponse response = InjectMetaDataToResponse(new RetrieveEntityResponse(), null, null, manyToManyRelationships, true);

            MockOrganizationService.Setup(a => a.Execute(It.IsAny <OrganizationRequest>())).Returns(response);

            FluentActions.Invoking(() => systemUnderTest.GetManyToManyEntityDetails(intersectEntityName))
            .Should()
            .NotThrow();

            MockOrganizationService.VerifyAll();
        }
Example #14
0
 private void SetupCurrentUser()
 {
     MockOrganizationService.Setup(x => x.GetCurrentUser(It.IsAny <CurrentUserRequest>())).Returns(GetOrganizationOneCurrentUserOne());
 }