Example #1
0
        public void Logout_WhenValid_ShouldReturnStatusCodeOk()
        {
            UserModel model = new UserModel()
            {
                Username    = "******",
                DisplayName = "Doncho Minkov1",
                AuthCode    = "tfff2dd4f1b310eb0dbf593bd83f94dd8d34077e"
            };

            var responseRegister = httpServer.Post("api/users/register", model);

            var contentString = responseRegister.Content.ReadAsStringAsync().Result;
            var userModel     = JsonConvert.DeserializeObject <UserLoggedModel>(contentString);

            var headers = new Dictionary <string, string>();

            headers["X-sessionKey"] = userModel.SessionKey;
            var response = httpServer.Put("api/users/logout", userModel, headers);

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
        }
        public void LeaveAComment_Whenvalid_ShouldreturnStatusCodeOK()
        {
            PostModel model = new PostModel()
            {
                Text  = "some text",
                Title = "my post",
            };
            UserModel user = new UserModel()
            {
                Username    = "******",
                DisplayName = "Doncho Minkov1",
                AuthCode    = "tfff2dd4f1b310eb0dbf593bd83f94dd8d34077e"
            };

            var responseRegister = httpServer.Post("api/users/register", user);

            var contentString = responseRegister.Content.ReadAsStringAsync().Result;
            var userModel     = JsonConvert.DeserializeObject <UserLoggedModel>(contentString);

            var headers = new Dictionary <string, string>();

            headers["X-sessionKey"] = userModel.SessionKey;
            var postResponse = httpServer.Post("api/posts", model, headers);

            var contentStringPost = postResponse.Content.ReadAsStringAsync().Result;
            var postModel         = JsonConvert.DeserializeObject <PostModel>(contentStringPost);

            CommentModel commentModel = new CommentModel()
            {
                Text = "some comment"
            };

            var commentResponse = httpServer.Put("api/posts/" + postModel.Id + "/comment", commentModel, headers);

            Assert.IsNotNull(commentResponse.Content);
            Assert.AreEqual(HttpStatusCode.OK, commentResponse.StatusCode);
        }