public void CreateNewUser_Authorized_201()
        {
            var controller = new UserManagementController();
            var admin      = _ut.CreateUserObject();

            admin.IsAdministrator = true;
            var adminSession = _ut.CreateSessionObject(admin);

            _ut.CreateSessionInDb(adminSession);

            // modify user
            var newUser = new {
                username = Guid.NewGuid() + "@mail.com",
                city     = "Long Beach",
                state    = "California",
                country  = "USA",
                manager  = "",
                isadmin  = false,
                disabled = false,
            };

            // mock payload
            var mock_payload = new CreateUserRequestDTO
            {
                Username = newUser.username,
                City     = newUser.city,
                State    = newUser.state,
                Country  = newUser.country,
                Manager  = newUser.manager,
                IsAdmin  = newUser.isadmin,
                Disabled = newUser.disabled
            };

            var expectedStatusCode = HttpStatusCode.Created;

            var endpoint = API_Route_Local + "/user/update";

            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri(endpoint)
            };
            controller.Request.Headers.Add("token", adminSession.Token);

            IHttpActionResult actionresult = controller.CreateNewUser(mock_payload);

            Assert.IsInstanceOfType(actionresult, typeof(NegotiatedContentResult <string>));
            var contentresult = actionresult as NegotiatedContentResult <string>;

            Assert.AreEqual(expectedStatusCode, contentresult.StatusCode);

            // persistence test
            using (var _db = _ut.CreateDataBaseContext())
            {
                var _userManager = new UserManagementManager(_db);
                var getUser      = _userManager.GetUser(newUser.username);
                Assert.AreNotEqual(newUser, getUser);
                Assert.AreEqual(newUser.isadmin, getUser.IsAdministrator);
            }
        }
        public void CreateNewUser_NonexistingManager_404()
        {
            var controller = new UserManagementController();
            var admin      = _ut.CreateUserObject();

            admin.IsAdministrator = true;
            var adminSession = _ut.CreateSessionObject(admin);

            _ut.CreateSessionInDb(adminSession);

            var nonexistingdManagerId = Guid.NewGuid();

            // modify user
            var newUser = new
            {
                username = Guid.NewGuid() + "@mail.com",
                city     = "Long Beach",
                state    = "California",
                country  = "USA",
                manager  = nonexistingdManagerId.ToString(),
                isadmin  = false,
                disabled = false,
            };

            // mock payload
            var mock_payload = new CreateUserRequestDTO
            {
                Username = newUser.username,
                City     = newUser.city,
                State    = newUser.state,
                Country  = newUser.country,
                Manager  = newUser.manager,
                IsAdmin  = newUser.isadmin,
                Disabled = newUser.disabled
            };

            var expectedStatusCode = HttpStatusCode.NotFound;

            var endpoint = API_Route_Local + "/user/update";

            controller.Request = new HttpRequestMessage
            {
                RequestUri = new Uri(endpoint)
            };
            controller.Request.Headers.Add("token", adminSession.Token);

            NegotiatedContentResult <string> actionresult = (NegotiatedContentResult <string>)controller.CreateNewUser(mock_payload);

            Assert.AreEqual(expectedStatusCode, actionresult.StatusCode);
        }