Exemple #1
0
        public void GetPostBySingleTag()
        {
            var testUser = new UserModel()
            {
                Username    = "******",
                DisplayName = "Valid DisplayName",
                AuthCode    = new string('*', 40)
            };

            var response      = httpServer.Post("api/users/register", testUser);
            var contentString = response.Content.ReadAsStringAsync().Result;

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            var userModel = JsonConvert.DeserializeObject <LoggedUserModel>(contentString);

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

            headers["X-sessionKey"] = userModel.SessionKey;

            var post = new PostModel()
            {
                Title = "Some title",
                Text  = "Some text",
                Tags  = new List <string>()
                {
                    "tag"
                }
            };

            httpServer.Post("api/posts", post, headers);
            var responseGet = httpServer.Get("api/posts?tags=" + post.Tags, headers);

            Assert.AreEqual(HttpStatusCode.OK, responseGet.StatusCode);
        }
Exemple #2
0
        public void TestGetPostsByValidTags_ShoudReturnValidPosts()
        {
            var testUser = new UserModel()
            {
                Username    = "******",
                DisplayName = "VALIDNICK",
                AuthCode    = new string('b', 40)
            };
            LoggedUserModel userModel = RegisterTestUser(httpServer, testUser);
            var             headers   = new Dictionary <string, string>();

            headers["X-sessionKey"] = userModel.SessionKey;

            var testPost = new Post()
            {
                Title = "Test post",
                Tags  = new List <Tag>()
                {
                    new Tag()
                    {
                        Name = "technology"
                    },
                    new Tag()
                    {
                        Name = "it"
                    },
                },
                Text = "this is just a test post"
            };

            httpServer.Post("api/posts", testPost, headers);

            var response = httpServer.Get("api/posts?tags=technology,it", headers);

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