private async Task TestServerConnection() { const string connectionTestCaption = "Test settings"; try { StringBuilder errorMessageBuilder = new StringBuilder(); if (!ValidateCalendarUrl(errorMessageBuilder)) { MessageBox.Show(errorMessageBuilder.ToString(), "The calendar Url is invalid", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var calDavDataAccess = SynchronizerFactory.CreateCalDavDataAccess( _calenderUrlTextBox.Text, _userNameTextBox.Text, _passwordTextBox.Text, TimeSpan.Parse(ConfigurationManager.AppSettings["calDavConnectTimeout"]), SelectedServerAdapterType); var cardDavDataAccess = SynchronizerFactory.CreateCardDavDataAccess( _calenderUrlTextBox.Text, _userNameTextBox.Text, _passwordTextBox.Text, TimeSpan.Parse(ConfigurationManager.AppSettings["calDavConnectTimeout"]), SelectedServerAdapterType); var isCalendar = await calDavDataAccess.IsResourceCalender(); var isAddressBook = await cardDavDataAccess.IsResourceAddressBook(); if (!isCalendar && !isAddressBook) { MessageBox.Show("The specified Url is neither a calendar nor an addressbook!", connectionTestCaption); return; } if (isCalendar && isAddressBook) { MessageBox.Show("Ressources which are a calendar and a addressbook are not valid!", connectionTestCaption); return; } bool hasError = false; errorMessageBuilder.Clear(); if (isCalendar) { hasError = await TestCalendar(calDavDataAccess, errorMessageBuilder); } if (isAddressBook) { hasError = await TestAddressBook(cardDavDataAccess, errorMessageBuilder); } if (hasError) { MessageBox.Show("Connection test NOT successful:" + Environment.NewLine + errorMessageBuilder.ToString(), connectionTestCaption); } else { MessageBox.Show("Connection test successful.", connectionTestCaption); } } catch (Exception x) { MessageBox.Show(x.Message, connectionTestCaption); } }