Ejemplo n.º 1
0
        private static Guid CreateNewRecord(CrmServiceClient crmSvc)
        {
            Dictionary <string, CrmDataTypeWrapper> inData = new Dictionary <string, CrmDataTypeWrapper>();

            inData.Add("name", new CrmDataTypeWrapper("account using crmSvc.CreateNewRecord", CrmFieldType.String));
            Guid Recordid2 = crmSvc.CreateNewRecord("account", inData);

            Console.WriteLine("Create Record {0}", Recordid2);
            return(Recordid2);
        }
        public void CreateNewRecordTest()
        {
            OrganizationRequest orgReq = null;
            Guid            respId     = Guid.NewGuid();
            MCreateResponse orgResp    = new MCreateResponse();

            orgResp.idGet = () => respId;
            BCrmServiceClient.AddResponse(typeof(CreateRequest), orgResp);
            BCrmServiceClient.MockCrmCommandExecute();
            Dictionary <string, CrmDataTypeWrapper> newFields = new Dictionary <string, CrmDataTypeWrapper>();

            newFields.Add("name", new CrmDataTypeWrapper("CrudTestAccount", CrmFieldType.String));
            newFields.Add("accountnumber", new CrmDataTypeWrapper("12345", CrmFieldType.String));
            newFields.Add("telephone1", new CrmDataTypeWrapper("555-555-5555", CrmFieldType.String));
            newFields.Add("donotpostalmail", new CrmDataTypeWrapper(true, CrmFieldType.CrmBoolean));
            Guid result = crmaction.CreateNewRecord("account", newFields);

            Assert.AreEqual(result, respId);
            result = crmaction.CreateNewRecord("", new Dictionary <string, CrmDataTypeWrapper>());
            Assert.AreNotEqual(result, respId);
            orgReq = BCrmServiceClient.GetRequest(typeof(CreateRequest));
            Assert.IsNotNull(((CreateRequest)orgReq).Target);
        }