private EmailServerDriver InstantiateEmailServerDriver()
        {
            var emailUrl            = EmailUtils.GetEmailUrl(PbUrl);
            var emailDriverSettings = new EmailServerDriverSettings(emailUrl);

            return(new EmailServerDriver(emailDriverSettings));
        }
        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);
        }
        public static async Task EmailServerDriver_ClearAllEmails_CallsDeleteAllEmails()
        {
            var settings = new EmailServerDriverSettings(new Uri("http://bjss.com/"));
            var driver   = new EmailServerDriver(settings);

            using var httpTest = new HttpTest();
            httpTest.RespondWithJson(new { });

            await driver.ClearAllEmailsAsync();

            httpTest.ShouldHaveCalled("http://bjss.com/email/all").WithVerb(HttpMethod.Delete);
        }
        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();
        public static async Task EmailServerDriver_GetEmailCountAsync_CallsGetAllEmails()
        {
            var settings     = new EmailServerDriverSettings(new Uri("http://bjss.com/"));
            var driver       = new EmailServerDriver(settings);
            var responseList = new List <EmailResponse>
            {
                EmailServerDriverResponseBuilder.Create().Build(),
                EmailServerDriverResponseBuilder.Create().Build(),
            };

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

            var resultCount = await driver.GetEmailCountAsync();

            resultCount.Should().Be(2);
            httpTest.ShouldHaveCalled("http://bjss.com/email").WithVerb(HttpMethod.Get);
        }