public void TestThatSentEmailIsPutIntoSentItemsFolder() { int iEmailLookbackPeriod = 1; SBEmailHeaders emailHeaders = new SBEmailHeaders(); m_connector.SetFolder("Sent Items"); m_connector.GetHeaders(iEmailLookbackPeriod, "ASC", ref emailHeaders); int numberOfEmailsPriorToSend = emailHeaders.NumberOfEntries; eResults result = m_connector.SendEmail(m_sUsername, "WebDAV Unit Test Send", 0, DateTime.Now.ToString(), eEmailBodyType.Text); Assert.That(result, Is.EqualTo(eResults.OK), "Call to SendEmail() failed.\n{0}", EmailServerInfo()); // Unfortunately we need to wait a little while before the sent e-mail shows up in the Sent Items folder. Thread.Sleep(5000); m_connector.GetHeaders(iEmailLookbackPeriod, "ASC", ref emailHeaders); int numberOfEmailsAfterSend = emailHeaders.NumberOfEntries; Assert.That(numberOfEmailsAfterSend, Is.GreaterThan(numberOfEmailsPriorToSend)); }
public void TestThatSentEmailIsPutIntoSentItemsFolder() { int iEmailLookbackPeriod = 1; SBEmailHeaders emailHeaders = new SBEmailHeaders(); m_connector.SetFolder("Sent Items"); m_connector.GetHeaders(iEmailLookbackPeriod, "ASC", ref emailHeaders); int numberOfEmailsPriorToSend = emailHeaders.NumberOfEntries; eResults result = m_connector.SendEmail(m_sUsername, "EWS Unit Test Send", 0, DateTime.Now.ToString(), eEmailBodyType.Text); Assert.That(result, Is.EqualTo(eResults.OK), "Call to SendEmail() failed.\n{0}", EmailServerInfo()); // At times the sent e-mail doesn't show up right away in the Sent Items folder. // To ensure that this doesn't cause the test to fail we'll just have to add a little wait here. Thread.Sleep(5000); m_connector.GetHeaders(iEmailLookbackPeriod, "ASC", ref emailHeaders); int numberOfEmailsAfterSend = emailHeaders.NumberOfEntries; Assert.That(numberOfEmailsAfterSend, Is.GreaterThan(numberOfEmailsPriorToSend)); }
public void TestThatNumberOfEmailsIsReturned() { SBEmailHeaders emailHeaders = new SBEmailHeaders(); eResults result = m_connector.GetHeaders(m_iEmailLookbackPeriod, "ASC", ref emailHeaders); Assert.That(result, Is.EqualTo(eResults.OK), "Call to GetHeaders() failed."); Assert.That(emailHeaders.NumberOfEntries, Is.GreaterThan(0), "For this test to work there must be at least one e-mail in the '{0}' folder within the last {1} days.\n{2}", m_sFolder, m_iEmailLookbackPeriod, EmailServerInfo()); }
public void TestThatNumberOfCalendarEntriesIsReturned() { SBCalendarEntries calendarEntries = new SBCalendarEntries(); eResults result = m_connector.GetCalendarEntries(DateTime.Now, m_iCalendarRetrievalPeriod, ref calendarEntries); Assert.That(result, Is.EqualTo(eResults.OK), "Call to GetCalendarEntries() failed."); Assert.That(calendarEntries.Count, Is.GreaterThan(0), "For this test to work there must be at least one calendar entry within the next {0} days.\n{1}", m_iCalendarRetrievalPeriod, EmailServerInfo()); }
public void TestThatEmptyInboxReturnsZeroEmails() { SBEmailHeaders emailHeaders = new SBEmailHeaders(); int iEmailLookkbackPeriod = -1; // This means we are looking for e-mails received tomorrow, which clearly there are none. eResults result = m_connector.GetHeaders(iEmailLookkbackPeriod, "ASC", ref emailHeaders); Assert.That(result, Is.EqualTo(eResults.OK), "Call to GetHeaders() failed."); Assert.That(emailHeaders.NumberOfEntries, Is.EqualTo(0), "Hmm, how is it possible that we found an e-mail in the '{0}' folder that we won't receive until tomorrow?\n{1}", m_sFolder, EmailServerInfo()); }
public void TestThatUsingIncorrectPasswordReturnsFail() { SBEmailHeaders emailHeaders = new SBEmailHeaders(); IConnector connector = new WebDavConnectorImplementation(eEmailServerType.Exchange2007WebDAV); connector.Init(m_Logger, m_sExchangeServerAddress, m_sFolder, m_sDomain, m_sUsername, m_bDebugAll); connector.Connect("Wrong Password"); eResults result = connector.GetHeaders(m_iEmailLookbackPeriod, "ASC", ref emailHeaders); Assert.That(result, Is.EqualTo(eResults.Fail)); }
public void TestThatEmptyCalendarPeriodReturnsZeroCalendarEntries() { SBCalendarEntries calendarEntries = new SBCalendarEntries(); DateTime dtStartDate = new DateTime(2012, 5, 24); //$$$ LP - This date & period were picked since the calendar for the sharris account didn't have any entries. int iCalendarRetrievalPeriod = 2; //$$$ LP - This date & period were picked since the calendar for the sharris account didn't have any entries. eResults result = m_connector.GetCalendarEntries(dtStartDate, iCalendarRetrievalPeriod, ref calendarEntries); Assert.That(result, Is.EqualTo(eResults.OK), "Call to GetCalendarEntries() failed."); Assert.That(calendarEntries.Count, Is.EqualTo(0), "For this test to work there must be no calendar entries between {0} and {1}.\n", dtStartDate, dtStartDate.AddDays(2)); //$$$ LP - Note that the end date displayed is not quite right since the actual end date calculation is more involved. Good enough for now but that whole calculation should really be refactored out of the connector implementation. }
private static void executeSearchEngine(string searchPhrase) { try { //Utlizamos dos variables, debido a que la ejecucion del algoritmo emplea dos hilos distintos y queremos evitar conflictos de asignacion de variables por cocurrencia urlGoogle = string.Format("{0}{1}", Shared.Variables.googleQueryUrl, searchPhrase); urlBing = string.Format("{0}{1}", Shared.Variables.BingQueryUrl, searchPhrase); Program obj = new Program(); Thread thr1 = new Thread(new ThreadStart(obj.runGoogleThread)); Thread thr2 = new Thread(new ThreadStart(obj.runBingThread)); thr1.SetApartmentState(ApartmentState.STA); thr1.Start(); thr2.SetApartmentState(ApartmentState.STA); thr2.Start(); thr2.Join(); //Aseguramos que culmine el hilo 2 antes de continuar. Thread.Sleep(4000); //el hilo 1 de google necesita que múltiples scripts js de la página se terminen de ejecutar, y al no recibir respusta de culminación controlamos la ejecucion de tiempo, sin embargo podría optimizarse. Utils.PrintToUser(string.Format("{0}\t\t\t Google:{1:n0}\tBing:{2:n0}", searchPhrase, Shared.Variables.resultNumberGoogle, Shared.Variables.resultNumberBing)); eResults res = new eResults(); res.searchProvider = "Google"; res.wordSearched = searchPhrase; res.numberResults = Shared.Variables.resultNumberGoogle; listadoResultados.Add(res); eResults res2 = new eResults(); res2.searchProvider = "Bing"; res2.wordSearched = searchPhrase; res2.numberResults = Shared.Variables.resultNumberBing; listadoResultados.Add(res2); } catch (Exception ex) { Utils.PrintToUser("Ocurrió un error, se reiniciará el programa", Variables.DANGER_COLOR); Initialize(); } }
public void TestThatAcceptingAMeetingRequestAddsTheMeetingIntoTheCalendar() { eResults result = eResults.OK; int iEmailLookbackPeriod = 1; int iMeetingTimePeriod = 3; string sTestRequirement = String.Format("For this test to work the following have to be true:\n" + " A meeting request with the subject \"WebDAV Meeting Request Test\" has to be received within the last {0} days.\n" + " The requested meeting has to occur within the next {1} days.\n{2}", iEmailLookbackPeriod, iMeetingTimePeriod, EmailServerInfo()); SBEmailHeaders emailHeaders = new SBEmailHeaders(); m_connector.GetHeaders(iEmailLookbackPeriod, "ASC", ref emailHeaders); // Look for the meeting request e-mail required by this test. bool bMeetingRequestFound = false; string sMeetingRequestId = null; for (int i = 0; (i < emailHeaders.NumberOfEntries && !bMeetingRequestFound); ++i) { if (emailHeaders[i].m_Type == eItemType.MeetingRequest) { if (emailHeaders[i].m_sSubject.ToLower() == "webdav meeting request test") { bMeetingRequestFound = true; sMeetingRequestId = emailHeaders[i].m_sId; } } } Assert.That(bMeetingRequestFound, Is.True, sTestRequirement); SBCalendarEntries calendarEntriesInitially = new SBCalendarEntries(); m_connector.GetCalendarEntries(DateTime.Now, iMeetingTimePeriod, ref calendarEntriesInitially); int iNumberOfTentativeMeetingsInitially = 0; int iNumberOfAcceptedMeetingsInitially = 0; for (int i = 0; i < calendarEntriesInitially.Count; ++i) { switch (calendarEntriesInitially[i].m_sBusystatus) { case "TENTATIVE": ++iNumberOfTentativeMeetingsInitially; break; case "BUSY": ++iNumberOfAcceptedMeetingsInitially; break; } } result = m_connector.SendMeetingRequestResp(sMeetingRequestId, "WebDAV Meeting Request Reponse Test", eMeetingRequestResp.Accept, true); Assert.That(result, Is.EqualTo(eResults.OK), "Call to SendMeetingRequestResp() failed.\n{0}", EmailServerInfo()); SBCalendarEntries calendarEntriesFinally = new SBCalendarEntries(); m_connector.GetCalendarEntries(DateTime.Now, iMeetingTimePeriod, ref calendarEntriesFinally); int iNumberOfTentativeMeetings = 0; int iNumberOfAcceptedMeetings = 0; for (int i = 0; i < calendarEntriesFinally.Count; ++i) { switch (calendarEntriesFinally[i].m_sBusystatus) { case "TENTATIVE": ++iNumberOfTentativeMeetings; break; case "BUSY": ++iNumberOfAcceptedMeetings; break; } } Assert.That((iNumberOfAcceptedMeetings - iNumberOfAcceptedMeetingsInitially), Is.EqualTo(1), "Number of accepted meetings hasn't changed as expected"); Assert.That((iNumberOfTentativeMeetings - iNumberOfTentativeMeetingsInitially), Is.EqualTo(-1), "Number of tentative meetings hasn't changed as expected"); }