Exemplo n.º 1
0
        public void ResetPassword()
        {
            unitOfWork.Data = Utils.CreateAdminAndUser();
            controller.Request.Headers.Authorization = new AuthenticationHeaderValue("jwt", "2");
            var result = controller.ResetPassword(1);

            Utils.AssertRequestMessageAndStatus(result, HttpStatusCode.Unauthorized);

            HttpContext.Current = Utils.GetDummyHttpContext();

            controller.Request.Headers.Authorization = new AuthenticationHeaderValue("jwt", "1");
            result = controller.ResetPassword(3);
            Utils.AssertRequestMessageAndStatus(result, HttpStatusCode.InternalServerError);

            result = controller.ResetPassword(2);
            Assert.IsNotInstanceOfType(result, typeof(HttpResponseMessage));
            Assert.IsTrue(unitOfWork.Saved);
            Assert.IsNull(unitOfWork.Data.Users.FirstOrDefault(u => u.id == 2)?.password);
            Assert.IsFalse(string.IsNullOrEmpty(mailHelper.Data.Subject));
        }