public void CreateOrUpdatePickListElementTest()
        {
            OrganizationRequest orgReq = null;
            Guid respId = Guid.NewGuid();
            MRetrieveEntityResponse rtventResp = new MRetrieveEntityResponse();
            MEntityMetadata         entmt      = new MEntityMetadata();

            entmt.IsCustomEntityGet      = () => { return(true); };
            rtventResp.EntityMetadataGet = () => { return(entmt); };
            BCrmServiceClient.AddResponse(typeof(RetrieveEntityRequest), rtventResp);
            BCrmServiceClient.MockCrmCommandExecute();
            List <AttributeData> lst1 = new List <AttributeData>();

            lst1.Add(new AttributeData());
            MDynamicEntityUtility.AllInstances.GetAttributeDataByEntityStringStringArray = (obj, str, arrstr) => { return(lst1); };
            List <LocalizedLabel> lst = new List <LocalizedLabel>();

            lst.Add(new LocalizedLabel());
            BCrmServiceClient.MockGetPickListElementFromMetadataEntity();
            bool result = crmaction.CreateOrUpdatePickListElement("account", "name", lst, 1, true);

            Assert.IsTrue(result);
            orgReq = BCrmServiceClient.GetRequest(typeof(InsertOptionValueRequest));
            Assert.IsNotNull(((InsertOptionValueRequest)orgReq).Value);
        }
        public void GetEntityTypeCodeTest()
        {
            OrganizationRequest     orgReq      = null;
            MRetrieveEntityResponse retriveResp = new MRetrieveEntityResponse();
            MEntityMetadata         ent         = new MEntityMetadata();

            ent.ObjectTypeCodeGet         = () => { return(1); };
            retriveResp.EntityMetadataGet = () => { return(ent); };
            BCrmServiceClient.AddResponse(typeof(RetrieveEntityRequest), retriveResp);
            BCrmServiceClient.MockCrmCommandExecute();
            string entityName = "account";
            string result     = crmaction.GetEntityTypeCode(entityName);

            Assert.IsNotNull(result);
            orgReq = BCrmServiceClient.GetRequest(typeof(RetrieveEntityRequest));
            Assert.AreEqual(entityName, ((RetrieveEntityRequest)orgReq).LogicalName);
        }
        public void GetAllAttributesForEntity()
        {
            OrganizationRequest        orgReq = null;
            List <AttributeMetadata>   AM     = new List <AttributeMetadata>();
            MRetrieveAttributeResponse resp   = new MRetrieveAttributeResponse();

            resp.AttributeMetadataGet = () => new AttributeMetadata();
            MEntityMetadata metadata = new MEntityMetadata();

            metadata.AttributesGet = () => new AttributeMetadata[1] {
                new AttributeMetadata()
            };
            MMetadataUtility.AllInstances.GetEntityMetadataString = (objMutility, str) => { return(metadata); };
            BCrmServiceClient.AddResponse(typeof(RetrieveAttributeRequest), resp);
            BCrmServiceClient.MockCrmCommandExecute();
            AM = crmaction.GetAllAttributesForEntity("contact");
            Assert.IsNotNull(AM);
        }
        public void GetAllEntityMetadata()
        {
            Guid respId = Guid.NewGuid();
            MRetrieveAllEntitiesResponse resp = new MRetrieveAllEntitiesResponse();
            MEntityMetadata mtdata            = new MEntityMetadata();

            mtdata.ObjectTypeCodeGet = () => 1;
            mtdata.LogicalNameGet    = () => "account";
            resp.EntityMetadataGet   = () => new EntityMetadata[1] {
                mtdata
            };
            BCrmServiceClient.AddResponse(typeof(RetrieveAllEntitiesRequest), resp);
            BCrmServiceClient.MockCrmCommandExecute();
            List <EntityMetadata> LM = new List <EntityMetadata>();

            LM = crmaction.GetAllEntityMetadata();
            Assert.IsNotNull(LM);
        }
        public void GetEntityNameTest()
        {
            MRetrieveAllEntitiesResponse retriveResp = new MRetrieveAllEntitiesResponse();
            MEntityMetadata ent = new MEntityMetadata();

            Nullable <int> no = 1;

            ent.ObjectTypeCodeGet = () => { return(no); };

            string st = "";

            ent.LogicalNameGet = () => { return(st); };

            EntityMetadata[] entmt = { ent };
            retriveResp.EntityMetadataGet = () => { return(entmt); };
            BCrmServiceClient.AddResponse(typeof(RetrieveAllEntitiesRequest), retriveResp);
            BCrmServiceClient.MockCrmCommandExecute();

            string result = crmaction.GetEntityName(1);

            Assert.IsNotNull(result);
        }