Esempio n. 1
0
        public async Task ThenTheAttachmentContainsTheFollowingData(string csvFile, Table table)
        {
            var emails = await emailServerDriver.FindAllEmailsAsync();

            var email      = emails[0];
            var attachment = email.Attachments.First(a => a.FileName.Contains(Path.ChangeExtension(csvFile, ".csv"), StringComparison.OrdinalIgnoreCase));

            using var attachmentReader = new StreamReader(new MemoryStream(attachment.AttachmentData.ToArray()));

            using var csvReader = new CsvReader(attachmentReader, CultureInfo.CurrentCulture);
            var csvRecords = csvReader.GetRecords <dynamic>().ToList();

            table.CompareToDynamicSet(csvRecords, new PreservePropertyNameFormatter(), false);
        }
        public static async Task EmailServerDriver_FindAllEmailsAsync_CallsFindsAllEmails()
        {
            var settings = new EmailServerDriverSettings(new Uri("http://email.com/"));
            var driver   = new EmailServerDriver(settings);

            var email = EmailServerDriverResponseBuilder.Create()
                        .WithSubject("Subject1")
                        .Build();

            var secondEmail = EmailServerDriverResponseBuilder.Create()
                              .WithSubject("Subject2")
                              .Build();

            var responseList = new List <EmailResponse> {
                email, secondEmail
            };

            using var httpTest = new HttpTest();
            httpTest.RespondWithJson(responseList);

            var resultEmails = await driver.FindAllEmailsAsync();

            httpTest.ShouldHaveCalled("http://email.com/email").WithVerb(HttpMethod.Get);
            resultEmails.Should().ContainSingle(e => e.Subject == email.Subject);
            resultEmails.Should().ContainSingle(e => e.Subject == secondEmail.Subject);
        }
Esempio n. 3
0
        public async Task ThenEmailContains(Table table)
        {
            var expectedEmail = table.CreateInstance <EmailTable>();
            var actualEmail   = (await emailServerDriver.FindAllEmailsAsync()).Last();

            var urlRegex = PasswordResetUrlRegex(expectedEmail.To);

            actualEmail.PlainTextBody.Should().MatchRegex(urlRegex);
            actualEmail.HtmlBody.Should().MatchRegex(urlRegex);
            actualEmail.Should().BeEquivalentTo(expectedEmail);

            var linkParser  = new Regex(urlRegex);
            var linkMatches = linkParser.Matches(actualEmail.PlainTextBody);

            linkMatches.Count.Should().Be(1, "there should only be one link in the email");

            var link = linkMatches.First().Value;

            context["EmailLink"] = link;
        }
        public async Task ThenTheResetUrlIsSentToTheE_MailAddress()
        {
            var user         = (User)Context["CreatedUser"];
            var currentCount = await EmailServerDriver.GetEmailCountAsync(Test.Url, user.Email);

            var precount = (int)Context["EmailCount"];

            currentCount.Should().BeGreaterThan(precount);
            var email = (await EmailServerDriver.FindAllEmailsAsync(Test.Url, user.Email)).Last();

            email.To.Should().BeEquivalentTo(user.Email);
            Context.Add("Email", email);
        }
        public static async Task EmailServerDriver_FindAllEmailsAsync_FieldsAreTheSame()
        {
            var settings = new EmailServerDriverSettings(new Uri("http://email.com/"));
            var driver   = new EmailServerDriver(settings);
            var email    = EmailServerDriverResponseBuilder.Create()
                           .WithSubject("Subject1")
                           .Build();

            var responseList = new List <EmailResponse> {
                email
            };

            using var httpTest = new HttpTest();
            httpTest.RespondWithJson(responseList);

            var resultEmail = (await driver.FindAllEmailsAsync()).Single();
Esempio n. 6
0
        public async Task OnlyOneEmailIsSent()
        {
            var emailCount = (await emailServerDriver.FindAllEmailsAsync()).Count;

            emailCount.Should().Be(1);
        }