Exemplo n.º 1
0
        public void Should_be_able_to_get_a_cms_item_by_key_and_date_and_time()
        {
            // Given
            var bootstrapper = new CustomBootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get("/cms/Homepage_Title_Background/201210202245/", with => with.HttpRequest());

            // Then
            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 2
0
        public void Should_be_able_to_get_root()
        {
            // Given
            var bootstrapper = new CustomBootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get("/", with => with.HttpRequest());

            // Then
            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }
Exemplo n.º 3
0
        public void Should_be_able_to_fail_a_get_on_a_random_key()
        {
            // Given
            var bootstrapper = new CustomBootstrapper();
            var browser = new Browser(bootstrapper);

            // When
            var result = browser.Get(string.Concat("/cms/" , DateTime.Now.Millisecond, "/"),
                with => with.HttpRequest());

            // Then
            Assert.Equal(HttpStatusCode.Gone, result.StatusCode);
        }
Exemplo n.º 4
0
    public void CheckCookie()
    {
      var bootstrapper = new CustomBootstrapper();
      var browser = new Browser(bootstrapper);

      var response = browser.Get("http://127.0.0.1/Poll/Register");
      var obj = JObject.Parse(response.Body.AsString()).ToObject<dynamic>();

      var sessionCookie = response.Cookies.FirstOrDefault(x => x.Name == "nancy_long_poll_session_id");
      Assert.IsNotNull(sessionCookie);

      var sessionId = sessionCookie.Value;
      Assert.IsFalse(string.IsNullOrWhiteSpace(sessionId));

      response = browser.Get("http://127.0.0.1/Poll/Register");
      obj = JObject.Parse(response.Body.AsString()).ToObject<dynamic>();

      sessionCookie = response.Cookies.FirstOrDefault(x => x.Name == "nancy_long_poll_session_id");
      Assert.IsNotNull(sessionCookie);
      var sessionId2 = sessionCookie.Value;
      Assert.IsFalse(string.IsNullOrWhiteSpace(sessionId));
      Assert.AreEqual(sessionId, sessionId2);
    }
Exemplo n.º 5
0
        public void Should_be_able_to_save_a_cms_item()
        {
            // Given

            var bootstrapper = new CustomBootstrapper();
            var browser = new Browser(bootstrapper);
            var streamReader = new StreamReader(Path.Combine(Environment.CurrentDirectory, "Content", "Logo.png"));
            var multipart = new BrowserContextMultipartFormData(x =>
                x.AddFile("Logo.png", "Logo.png", "image/png", streamReader.BaseStream));
            // When
            var result = browser.Post("/cms/",
                                      delegate(BrowserContext with)
                                      {
                                          with.HttpRequest();
                                          with.FormValue("key", "Homepage_Title_Background");
                                          with.MultiPartFormData(multipart);

                                      });

            // Then
            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }