Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void SignOut()
- {
- Initialize();
- HttpContext current = HttpContext.Current;
- bool flag = current.CookielessHelper.DoesCookieValueExistInOriginal('F');
- current.CookielessHelper.SetCookieValue('F', null);
- if (!CookielessHelperClass.UseCookieless(current, false, CookieMode) || current.Request.Browser.Cookies)
- {
- string str = string.Empty;
- if (current.Request.Browser["supportsEmptyStringInCookieValue"] == "false")
- {
- str = "NoCookie";
- }
- HttpCookie cookie = new HttpCookie(FormsCookieName, str);
- cookie.HttpOnly = true;
- cookie.Path = _FormsCookiePath;
- cookie.Expires = new DateTime(0x7cf, 10, 12);
- cookie.Secure = _RequireSSL;
- if (_CookieDomain != null)
- {
- cookie.Domain = _CookieDomain;
- }
- current.Response.Cookies.RemoveCookie(FormsCookieName);
- current.Response.Cookies.Add(cookie);
- }
- if (flag)
- {
- current.Response.Redirect(GetLoginPage(null), false);
- }
- }
- current.Request.Browser["supportsEmptyStringInCookieValue"]
- HttpContext.Current.Request.Browser.SupportsEmptyStringInCookieValue
- CookielessHelperClass.UseCookieless(current, false, CookieMode)
- HttpContext.Current.Request.Browser = new HttpBrowserCapabilities() { Capabilities = new Dictionary<string, string> { { "supportsEmptyStringInCookieValue", "false" } } };
- public interface IFormsAuthenticationWrap
- {
- void SignOut();
- }
- public class FormsAuthenticationWrap : IFormsAuthenticationWrap
- {
- public void SignOut()
- {
- FormsAuthentication.SignOut();
- }
- }
- public class LogOutClass
- {
- private readonly IFormsAuthenticationWrap _formsAuthentication;
- public LogOutClass() : this (new FormsAuthenticationWrap())
- {
- }
- public LogOutClass(IFormsAuthenticationWrap formsAuthentication)
- {
- _formsAuthentication = formsAuthentication;
- }
- public void LogOutMethod()
- {
- // Code before SignOut
- _formsAuthentication.SignOut();
- // Code after SignOut
- }
- }
- public class FormsAuthenticationStub : IFormsAuthenticationWrap
- {
- public void SignOut()
- {
- }
- }
- [TestMethod]
- public void TestLogOutMethod()
- {
- var logOutClass = new LogOutClass(new FormsAuthenticationStub());
- logOutClass.LogOutMethod();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement