Exemplo n.º 1
0
        public void ShouldRedirectToLoginWithSecureRequest()
        {
            var bootstrapper = new CustomTestBootstrapper();
            var browser      = new Browser(bootstrapper);

            BrowserResponse response = browser.Get("/admin", with => { with.HttpRequest(); });

            response.ShouldHaveRedirectedTo("/login?returnUrl=/admin");
        }
        public void TestBrowserReturnsSuccess()
        {
            var bootstrapper = new CustomTestBootstrapper();
            var browser      = new Browser(bootstrapper);

            BrowserResponse response = browser.Get("/", with => { with.HttpRequest(); });

            Assert.That(HttpStatusCode.OK, Is.EqualTo(response.StatusCode));
        }
Exemplo n.º 3
0
        public void ShouldDisplayFormElements()
        {
            var bootstrapper = new CustomTestBootstrapper();
            var browser      = new Browser(bootstrapper);

            BrowserResponse response = browser.Get("/SignUp", with => { with.HttpRequest(); });

            response.Body ["form#signUpForm input#ClientName"].ShouldExistOnce();
            response.Body ["form#signUpForm input#ContactName"].ShouldExistOnce();
            response.Body ["form#signUpForm input#ContactPhone"].ShouldExistOnce();
        }
Exemplo n.º 4
0
        public void ShouldAccessLoginAfterSuccessfulLogin()
        {
            var bootstrapper = new CustomTestBootstrapper();
            var browser      = new Browser(bootstrapper);

            BrowserResponse response = browser.Post("/login", (with) => {
                with.HttpRequest();
                with.FormValue("Username", "admin");
                with.FormValue("Password", "password");
            });

            response.ShouldHaveRedirectedTo("/admin");
        }
Exemplo n.º 5
0
        public void LoggingInMaintainsSession()
        {
            var bootstrapper = new CustomTestBootstrapper();
            var browser      = new Browser(bootstrapper);

            BrowserResponse response = browser.Post("/login", (with) => {
                with.HttpRequest();
                with.FormValue("Username", "admin");
                with.FormValue("Password", "password");
            });

            response = browser.Get("/admin");
            string innerText = response.Body ["div#site-content h2"].ShouldExistOnce().And.InnerText;

            Assert.That(innerText, Is.EqualTo("Client Manager Admin Home"));
        }
Exemplo n.º 6
0
        public void ShouldShowMessageWithNullInput()
        {
            IClientService clientService = new ClientService();
            var            bootstrapper  = new CustomTestBootstrapper(clientService);
            var            browser       = new Browser(bootstrapper);

            BrowserResponse response = browser.Post("/SignUp", (with) => {
                with.HttpRequest();
                with.FormValue("ContactName", "James Dean");
                with.FormValue("ContactPhone", "8008674309");
                with.FormValue("ContactEmail", "*****@*****.**");
            });

            string validationText = response.Body ["div#ValidationText p"].ShouldExistOnce().And.InnerText;

            Assert.That(validationText, Is.StringContaining("The client name, contact name, and contact phone must be present when signing up!"));
        }
Exemplo n.º 7
0
        public void ShouldReturnMessageWithDuplicateContactEmail()
        {
            IClientService clientService = new ClientService();
            var            bootstrapper  = new CustomTestBootstrapper(clientService);
            var            browser       = new Browser(bootstrapper);

            var clients = clientService.GetAll();

            BrowserResponse response = browser.Post("/SignUp", (with) => {
                with.HttpRequest();
                with.FormValue("ClientName", "Unique client name");
                with.FormValue("ContactName", "James Dean");
                with.FormValue("ContactPhone", "8008674309");
                with.FormValue("ContactEmail", clients.First().ContactEmail);
            });

            string validationText = response.Body ["div#ValidationText p"].ShouldExistOnce().And.InnerText;

            Assert.That(validationText, Is.StringContaining("The contact email is already assigned to another client!"));
        }
Exemplo n.º 8
0
        public void ShouldCreateClientWithNewSignUp()
        {
            var clientService = new ClientService();
            var bootstrapper  = new CustomTestBootstrapper(clientService);
            var browser       = new Browser(bootstrapper);

            BrowserResponse response = browser.Post("/SignUp", (with) => {
                with.HttpRequest();
                with.FormValue("ClientName", "Unique Client Name");
                with.FormValue("ContactName", "James Dean");
                with.FormValue("ContactPhone", "8008674309");
                with.FormValue("ContactEmail", "*****@*****.**");
            });

            response.ShouldHaveRedirectedTo("/SignUp/ThankYou");

            var clients = clientService.GetAll();

            Assert.IsTrue(clients.Any(c => c.ClientName.ToString().Equals("Unique Client Name")));
        }
Exemplo n.º 9
0
        public void ShouldDisplaySignUpLink()
        {
            var bootstrapper = new CustomTestBootstrapper();
            var browser      = new Browser(bootstrapper);

            BrowserResponse response  = browser.Get("/", with => { with.HttpRequest(); });
            string          fieldText = response.Body ["div#SignUpWelcome a"].ShouldExistOnce().And.InnerText;

            Assert.That(fieldText, Is.EqualTo("Sign Up"));
            string linkText = response.Body ["div#SignUpWelcome a"].ShouldExistOnce().And.Attributes["href"];

            Assert.That(linkText, Is.EqualTo("/SignUp"));

            response = browser.Get(linkText, with => {
                with.HttpRequest();
            });

            string signUpTitleText = response.Body ["h2"].ShouldExistOnce().And.InnerText;

            Assert.That(signUpTitleText, Is.EqualTo("Sign Up for an Account!"));
        }