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()
{
cbxOragnization.Items.Clear();
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);
discoveryProxy.Authenticate();
try
{
RetrieveOrganizationsRequest retrieveOrganizationsRequest = new RetrieveOrganizationsRequest();
RetrieveOrganizationsResponse retrieveOrganizationsResponse = discoveryProxy.Execute(retrieveOrganizationsRequest) as RetrieveOrganizationsResponse;
if (retrieveOrganizationsResponse.Details.Count != 0)
{
foreach (OrganizationDetail orgInfo in retrieveOrganizationsResponse.Details)
orgNames.Add(orgInfo.UrlName);
}
}
catch (Exception)
{
throw new InvalidOperationException();
}
cbxOragnization.Items.AddRange(orgNames.ToArray());
cbxOragnization.SelectedIndex = 0;
cbxOragnization.Focus();
}
thank you