コード例 #1
0
        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);
        }
コード例 #2
0
        public LoggingServiceUT()
        {
            _ls = new LoggingService();
            _tu = new TestingUtils();

            newUser    = _tu.CreateUserObject();
            newSession = _tu.CreateSessionObject(newUser);
            _tu.CreateSessionInDb(newSession);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }