public void LogoutValidUserTest() { using (TransactionScope transaction = new TransactionScope()) { 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; UserLogoutRequestModel logoutModel = new UserLogoutRequestModel() { SessionKey = userModel.SessionKey }; var response = this.LogoutTestUser(httpServer, logoutModel, headers); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Content); } }
public void GetPostsTest() { 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>(), Text = "Basdlksdflksdfsdlfkj" }; var response = CreatePost(httpServer, postModel, headers); Assert.AreEqual(HttpStatusCode.OK, response.StatusCode); Assert.IsNotNull(response.Content); }
public void RegisterUserWithAuthCodeMissingTest() { using (TransactionScope transaction = new TransactionScope()) { UserRegisterRequestModel testUser = new UserRegisterRequestModel() { Username = "******", DisplayName = "validnick", }; var response = RegisterTestUser(httpServer, testUser); Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); } }
public void RegisterAlreadyExistingUserTest() { using (TransactionScope transaction = new TransactionScope()) { UserRegisterRequestModel testUser = new UserRegisterRequestModel() { Username = "******", DisplayName = "validnick", AuthCode = new string('b', 40) }; var response = RegisterTestUser(httpServer, testUser); var existingUserResponse = RegisterTestUser(httpServer, testUser); Assert.AreEqual(HttpStatusCode.Created, response.StatusCode); Assert.AreEqual(HttpStatusCode.BadRequest, existingUserResponse.StatusCode); } }
private UserRegisterResponseModel RegisterTestUserWithSKey(InMemoryHttpServer httpServer, UserRegisterRequestModel testUser) { var response = httpServer.Post("api/users/register", testUser); var contentString = response.Content.ReadAsStringAsync().Result; var userModel = JsonConvert.DeserializeObject<UserRegisterResponseModel>(contentString); return userModel; }
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); }