public void DeleteUser_NoUserId_412() { newUser = _tu.CreateUserObject(); Session newSession = _tu.CreateSessionObject(newUser); _tu.CreateSessionInDb(newSession); var endpoint = API_ROUTE_LOCAL + "/users/delete/"; _umController.Request = new HttpRequestMessage { RequestUri = new Uri(endpoint) }; var request = new HttpRequestMessage(); request.Headers.Add("token", newSession.Token); _umController.Request = request; //passing null parameter creates InvalidModelPayloadException that should be caught // and return a 400 NegotiatedContentResult <string> response = (NegotiatedContentResult <string>)_umController.DeleteUser((string)null); Assert.AreEqual(HttpStatusCode.PreconditionFailed, response.StatusCode); }
public LoggingServiceUT() { _ls = new LoggingService(); _tu = new TestingUtils(); newUser = _tu.CreateUserObject(); newSession = _tu.CreateSessionObject(newUser); _tu.CreateSessionInDb(newSession); }
public void GetAllUsers_Authorized_200() { var controller = new UserManagementController(); var admin = _ut.CreateUserObject(); admin.IsAdministrator = true; var adminSession = _ut.CreateSessionObject(admin); _ut.CreateSessionInDb(adminSession); var expectedStatusCode = HttpStatusCode.OK; var endpoint = API_Route_Local + "/users"; controller.Request = new HttpRequestMessage { RequestUri = new Uri(endpoint) }; controller.Request.Headers.Add("token", adminSession.Token); IHttpActionResult actionresult = controller.GetAllUsers(); Assert.IsInstanceOfType(actionresult, typeof(NegotiatedContentResult <List <GetAllUsersResponseDataItem> >)); var contentresult = actionresult as NegotiatedContentResult <List <GetAllUsersResponseDataItem> >; Assert.AreEqual(expectedStatusCode, contentresult.StatusCode); }
public void ReadPoint_200() { newUser = _tu.CreateUserObject(); Session newSession = _tu.CreateSessionObject(newUser); _tu.CreateSessionInDb(newSession); var point = _tu.CreatePointObject(179, 81); point = _tu.CreatePointInDb(point); var endpoint = API_ROUTE_LOCAL + "/api/point/" + point.Id; controller.Request = new HttpRequestMessage { RequestUri = new Uri(endpoint) }; var request = new HttpRequestMessage(); request.Headers.Add("token", newSession.Token); controller.Request = request; OkNegotiatedContentResult <Point> response = (OkNegotiatedContentResult <Point>)controller.Get(point.Id.ToString()); Assert.AreEqual(point.Name, response.Content.Name); Assert.AreEqual(point.Description, response.Content.Description); Assert.AreEqual(point.Longitude, response.Content.Longitude); Assert.AreEqual(point.Latitude, response.Content.Latitude); }