public void ExecuteWorkflowOnEntityTest()
        {
            OrganizationRequest orgReq = null;
            Guid respId = Guid.NewGuid();
            MExecuteWorkflowResponse exwResp = new MExecuteWorkflowResponse();

            exwResp.IdGet = () => { return(respId); };
            MRetrieveMultipleResponse rtvresp = new MRetrieveMultipleResponse();
            EntityCollection          entcoll = new EntityCollection();

            entcoll.Entities.Add(new Entity());
            rtvresp.EntityCollectionGet = () => { return(entcoll); };
            BCrmServiceClient.AddResponse(typeof(ExecuteWorkflowRequest), exwResp);
            BCrmServiceClient.AddResponse(typeof(RetrieveMultipleRequest), rtvresp);
            BCrmServiceClient.MockCrmCommandExecute();
            MCrmServiceClient.AllInstances.GetDataByKeyFromResultsSetDictionaryOfStringObjectString <Guid>((objwbsvcaction, dict, str) =>
            {
                if (str == "parentworkflowid")
                {
                    return(Guid.Empty);
                }
                else
                {
                    return((Guid)respId);
                }
            });
            Guid result = crmaction.ExecuteWorkflowOnEntity("workflow1", respId);

            Assert.AreEqual(respId, result);
            orgReq = BCrmServiceClient.GetRequest(typeof(ExecuteWorkflowRequest));
            Assert.IsNotNull(((ExecuteWorkflowRequest)orgReq).WorkflowId);
        }
        public void GetEntityDataByFetchSearchTest()
        {
            OrganizationRequest orgReq = null;
            Guid respId = Guid.NewGuid();
            MRetrieveMultipleResponse rtrResp = new MRetrieveMultipleResponse();
            EntityCollection          entColl = new EntityCollection();

            entColl.Entities.Add(new Entity());
            rtrResp.EntityCollectionGet = () => { return(entColl); };
            MFetchXmlToQueryExpressionResponse ftcrsp = new MFetchXmlToQueryExpressionResponse();

            ftcrsp.QueryGet = () => { return(new QueryExpression()); };
            BCrmServiceClient.AddResponse(typeof(FetchXmlToQueryExpressionRequest), ftcrsp);
            BCrmServiceClient.AddResponse(typeof(RetrieveMultipleRequest), rtrResp);
            BCrmServiceClient.MockCrmCommandExecute();
            string fetch = "<fetch mapping='logical'>";

            fetch += "<entity name='account'><all-attributes/>";
            fetch += "</entity></fetch>";
            Dictionary <string, Dictionary <string, object> > Results = crmaction.GetEntityDataByFetchSearch(fetch);

            Assert.IsNotNull(Results);
            string strCookie;
            bool   blnmoreRecord;

            Results = crmaction.GetEntityDataByFetchSearch(fetch, 1, 1, "", out strCookie, out blnmoreRecord);
            Assert.IsNotNull(Results);
            orgReq = BCrmServiceClient.GetRequest(typeof(RetrieveMultipleRequest));
            Assert.IsNotNull(((RetrieveMultipleRequest)orgReq).Query);
        }
        public void GetEntityDataByLinkedSearchTest()
        {
            OrganizationRequest orgReq = null;
            Guid respId = Guid.NewGuid();

            MRetrieveMultipleResponse rtrResp = new MRetrieveMultipleResponse();
            EntityCollection          entColl = new EntityCollection();

            entColl.Entities.Add(new Entity());
            rtrResp.EntityCollectionGet = () => { return(entColl); };
            BCrmServiceClient.AddResponse(typeof(RetrieveMultipleRequest), rtrResp);
            BCrmServiceClient.MockCrmCommandExecute();
            Dictionary <string, Dictionary <string, object> > result = crmaction.GetEntityDataByLinkedSearch("account", new Dictionary <string, string>(), "contact", new Dictionary <string, string>(), "", "", "", new CrmServiceClient.LogicalSearchOperator(), new List <string>());

            Assert.IsNotNull(result);
            orgReq = BCrmServiceClient.GetRequest(typeof(RetrieveMultipleRequest));
            Assert.IsNotNull(((RetrieveMultipleRequest)orgReq).Query);
        }
        public void AddEntityToQueueTest()
        {
            OrganizationRequest orgReq = null;
            Guid respId = Guid.NewGuid();
            MRetrieveMultipleResponse rtvResp = new MRetrieveMultipleResponse();
            EntityCollection          entcol  = new EntityCollection();

            entcol.Entities.Add(new Entity());
            rtvResp.EntityCollectionGet = () => { return(entcol); };
            BCrmServiceClient.AddResponse(typeof(RetrieveMultipleRequest), rtvResp);
            BCrmServiceClient.MockCrmCommandExecute();
            MCrmServiceClient.AllInstances.GetDataByKeyFromResultsSetDictionaryOfStringObjectString <Guid>((objsvcact, dct, str) => { return(respId); });
            bool result = crmaction.AddEntityToQueue(respId, "account", "que", respId);

            Assert.IsTrue(result);
            orgReq = BCrmServiceClient.GetRequest(typeof(AddToQueueRequest));
            Assert.IsNotNull(((AddToQueueRequest)orgReq).DestinationQueueId);
            Assert.IsNotNull(((AddToQueueRequest)orgReq).Target);
        }