public override void TestFixtureSetUp() { // clear all existing users except the HOST superuser DatabaseHelper.ExecuteNonQuery("DELETE FROM {objectQualifier}UserRelationships"); DatabaseHelper.ExecuteNonQuery("DELETE FROM {objectQualifier}UserPortals"); DatabaseHelper.ExecuteNonQuery("DELETE FROM {objectQualifier}Users WHERE UserID > 1"); // create MaxUsers new users for (var i = 0; i < MaxUsers; i++) { int userId, fileId; string userName; WebApiTestHelper.PrepareNewUser(out userId, out userName, out fileId); this._userIds[i] = userId; this._userNames[i] = userName; Console.WriteLine(@"Created test users => id: {0}, username: {1}", userId, userName); } var hostConnector = WebApiTestHelper.LoginHost(); var userIdx = 0; // make first user as admin var makeAdminItem = new { RoleId = 0, UserId = this._userIds[userIdx] }; var response = hostConnector.PostJson(MakeAdminApi, makeAdminItem).Content.ReadAsStringAsync().Result; var result = JsonConvert.DeserializeObject <dynamic>(response); Assert.AreEqual(this._userNames[userIdx], result.displayName.ToString()); // Unauthorize the next 2 new users for (userIdx = 1; userIdx <= 2; userIdx++) { var unauthorizeLink = string.Format(UnauthorizeApi, this._userIds[userIdx]); response = hostConnector.PostJson(unauthorizeLink, string.Empty).Content.ReadAsStringAsync().Result; result = JsonConvert.DeserializeObject <dynamic>(response); Assert.IsTrue(bool.Parse(result.Success.ToString())); } // soft delete the next new user var deleteLink = string.Format(DeleteApi, this._userIds[userIdx]); response = hostConnector.PostJson(deleteLink, string.Empty).Content.ReadAsStringAsync().Result; result = JsonConvert.DeserializeObject <dynamic>(response); Assert.IsTrue(bool.Parse(result.Success.ToString())); }
private IWebApiConnector CreateNewUser(out int userId, out string username, out int fileId) { return(WebApiTestHelper.PrepareNewUser(out userId, out username, out fileId, PortalId)); }