public void MakeACommentForPostTest() { UserRegisterRequestModel testUser = new UserRegisterRequestModel() { Username = "******", DisplayName = "validnick", AuthCode = new string('b', 40) }; UserRegisterResponseModel userModel = RegisterTestUserWithSKey(httpServer, testUser); var headers = new Dictionary<string, string>(); headers["X-sessionKey"] = userModel.SessionKey; PostResponseDetailedModel postModel = new PostResponseDetailedModel() { Title = "Test Post Title", Tags = new List<string>() { "web" }, Text = "Basdlksdflksdfsdlfkj" }; CommentInPostModel commentModel = new CommentInPostModel() { Text = "Mocking is nice!" }; var returnedModel = CreatePostAndReturnModel(httpServer, postModel, headers); var getResponse = MakeCommentForPost(httpServer, returnedModel.Id, commentModel, headers); Assert.AreEqual(HttpStatusCode.Created, getResponse.StatusCode); }
private HttpResponseMessage MakeCommentForPost(InMemoryHttpServer httpServer, int postId, CommentInPostModel commentModel, Dictionary<string, string> headers) { var response = httpServer.Put("api/posts/" + postId + "/comment", commentModel, headers); var contentString = response.Content.ReadAsStringAsync().Result; //var returnedPostModel = JsonConvert.DeserializeObject<PostResponseDetailedModel>(contentString); return response; }