public void ThenTheyReceiveAConfirmationCodeByEmailAndCanVerifyTheirAccount() { var inboxId = _scenarioContext.Get <Guid>("inboxId"); var emailAddress = _scenarioContext.Get <string>("emailAddress"); var waitForControllerApi = new WaitForControllerApi(_mailslurpConfig); var email = waitForControllerApi.WaitForLatestEmail(inboxId: inboxId, timeout: TimeoutMillis, unreadOnly: true); // verify the contents email.Subject.Should().Contain("Please confirm your email address"); // we need to get the confirmation code from the email var rx = new Regex(@".*verification code is (\d{6}).*", RegexOptions.Compiled); var match = rx.Match(email.Body); var confirmationCode = match.Groups[1].Value; confirmationCode.Length.Should().Be(6); // fill the confirm user form with the confirmation code we got from the email _webdriver.FindElement(By.Name("code")).SendKeys(confirmationCode); _webdriver.FindElement(By.CssSelector("[data-test=confirm-sign-up-confirm-button]")).Click(); // load the main page again _webdriver.Navigate().GoToUrl("https://playground.mailslurp.com"); // login with email and password (we expect it to work now that we are confirmed) _webdriver.FindElement(By.Name("username")).SendKeys(emailAddress); _webdriver.FindElement(By.Name("password")).SendKeys(Password); _webdriver.FindElement(By.CssSelector("[data-test=sign-in-sign-in-button]")).Click(); // verify that user can see authenticated content _webdriver.FindElement(By.TagName("h1")).Text.Contains("Welcome").Should().BeTrue(); }
public void CanReceiveConfirmationEmail() { // now fetch the email that playground sends us var waitForControllerApi = new WaitForControllerApi(_mailslurpConfig); _email = waitForControllerApi.WaitForLatestEmail(inboxId: _inbox.Id, timeout: TimeoutMillis, unreadOnly: true); // verify the contents Assert.IsTrue(_email.Subject.Contains("Please confirm your email address")); }
private static void AssertInboxEmails(Inbox inbox, int num, long timeout) { var waitForInstance = new WaitForControllerApi(_fixture.Config); var list = waitForInstance.WaitForEmailCount(num, inbox.Id, timeout, true); Assert.IsNotNull(list); Assert.AreEqual(num, list.Count); foreach (var e in list) { Assert.IsNotNull(e.Subject); } }
public void CanSendEmail_ThenReceiveIt() { // first configure your api key var config = new Configuration(); config.ApiKey.Add("x-api-key", YourApiKey); // create two inboxes var apiInstance = new InboxControllerApi(config); var inbox1 = apiInstance.CreateInbox(); var inbox2 = apiInstance.CreateInbox(); Assert.NotEqual(inbox1.EmailAddress, inbox2.EmailAddress); // send email from inbox1 to inbox2 var sendEmailOptions = new SendEmailOptions() { To = new List <string>() { inbox2.EmailAddress }, Subject = "Hello inbox2", Body = "Your code is: 123" }; apiInstance.SendEmail(inbox1.Id, sendEmailOptions); // wait for email in inbox2 and read it var waitForInstance = new WaitForControllerApi(config); var email = waitForInstance.WaitForLatestEmail(inbox2.Id, Timeout, UnreadOnly); Assert.NotNull(email); Assert.Equal(inbox1.EmailAddress, email.From); Assert.Equal("Hello inbox2", email.Subject); Assert.Contains("Your code is: ", email.Body); // extract a code from email body var rx = new Regex(@"Your code is: ([0-9]{3})", RegexOptions.Compiled); var match = rx.Match(email.Body); var code = match.Groups[1].Value; Assert.Equal("123", code); }
public WaitForControllerApiTests() { instance = new WaitForControllerApi(); }