public void ActivateUser() { unitOfWork.Data = Utils.CreateAdminAndUser(); //GetSiteUrl needs this HttpContext.Current = Utils.GetDummyHttpContext(); controller.Request.Headers.Authorization = new AuthenticationHeaderValue("jwt", "2"); var result = controller.Activate(2); Assert.IsInstanceOfType(result, typeof(HttpResponseMessage)); var message = result as HttpResponseMessage; Assert.AreEqual(HttpStatusCode.Unauthorized, message?.StatusCode); controller.Request.Headers.Authorization = new AuthenticationHeaderValue("jwt", "1"); result = controller.Activate(2); Assert.IsNotInstanceOfType(result, typeof(HttpResponseMessage)); Assert.IsFalse(string.IsNullOrEmpty(mailHelper.Data.Subject)); result = controller.Activate(3); Assert.IsInstanceOfType(result, typeof(HttpResponseMessage)); message = result as HttpResponseMessage; Assert.AreEqual(HttpStatusCode.InternalServerError, message?.StatusCode); }