Unit test CRM RRS feed

  • Question

  • Hello,

    this is my first i work with unit test ,

    Please Help me to do a methode test for this function, just i want an example to khnow how i will work with anather methode

    this is my function GetOrganization for find the organization name for the server name if the deployment Type is on premise or online

    rivate void GetOrganization()
                List<string> orgNames = new List<string>();
                userCredentials.UserName.UserName = txtName.Text.Trim();
                userCredentials.UserName.Password = txtPassword.Text.Trim();
                string serverName = txtServer.Text.Trim();
                string deployType = cbxDep.Text;
                string region = cbxOnlineR.Text;
                bool isOffice = rdBtOffice.Checked;
                bool isMicrosoft = rdBtnMS.Checked;
                var  crmURI = "";
                if (deployType == "On-premises")
                    crmURI = "http://" + serverName + "/XRMServices/2011/Discovery.svc";
                else if (deployType == "Online")
                    crmURI = CRMHelpers.GetDiscoveryUrl(region, isOffice, isMicrosoft);
                    DiscoveryServiceProxy discoveryProxy = new DiscoveryServiceProxy(new Uri(crmURI), null, userCredentials, null);
                  RetrieveOrganizationsRequest retrieveOrganizationsRequest = new RetrieveOrganizationsRequest();
                    RetrieveOrganizationsResponse retrieveOrganizationsResponse = discoveryProxy.Execute(retrieveOrganizationsRequest) as RetrieveOrganizationsResponse;
                    if (retrieveOrganizationsResponse.Details.Count != 0)
                        foreach (OrganizationDetail orgInfo in retrieveOrganizationsResponse.Details)
                           catch (Exception)
                    throw new InvalidOperationException();
                cbxOragnization.SelectedIndex = 0;

    thank you

    Friday, March 13, 2015 4:11 PM