public void UpdatePassword_WithEmptyPassword_ThrowsArgumentNullException()
        {
            // Arrange
            var context = new Mock<ISubtextContext>();
            var accountService = new AccountService(context.Object);

            // Act, Assert
            UnitTestHelper.AssertThrows<ArgumentNullException>(() =>
                accountService.UpdatePassword(null));
            UnitTestHelper.AssertThrows<ArgumentNullException>(() =>
                accountService.UpdatePassword(""));
        }
        public void UpdatePassword_WithNonEmptyPassword_HashesPassword()
        {
            // Arrange
            var blog = new Blog { IsPasswordHashed = true };
            var context = new Mock<ISubtextContext>();
            context.Setup(c => c.Repository.UpdateBlog(blog));
            context.Setup(c => c.Blog).Returns(blog);
            var accountService = new AccountService(context.Object);

            // Act
            accountService.UpdatePassword("newPass");

            // Assert
            string expected = SecurityHelper.HashPassword("newPass");
            Assert.AreEqual(expected, blog.Password);
        }
        public void Logout_ClearsAuthCookie()
        {
            // arrange
            var responseCookies = new HttpCookieCollection();
            var context = new Mock<ISubtextContext>();
            var existingCookies = new HttpCookieCollection();
            existingCookies.Add(new HttpCookie(".ASPXAUTH.HA.null"));
            context.Setup(c => c.HttpContext.Request.Cookies).Returns(existingCookies);
            context.Setup(c => c.HttpContext.Request.QueryString).Returns(new NameValueCollection());
            context.Setup(c => c.HttpContext.Response.Cookies).Returns(responseCookies);
            var service = new AccountService(context.Object);

            // act
            service.Logout();

            // assert
            Assert.AreEqual(1, responseCookies.Count);
            Assert.IsTrue(responseCookies[0].Expires < DateTime.UtcNow);
        }