Ejemplo n.º 1
0
        public void DrpAccount_SelectedIndexChanged_CreateCookie_Redirect()
        {
            // Arrange
            InitializeAuthTests();
            var drpClient = new DropDownList();

            drpClient.Items.Add("1");
            drpClient.SelectedValue = "1";
            _accountsHomePagePrivate.SetField("drpClient", drpClient);
            var drpclientgroup = new DropDownList {
            };

            drpclientgroup.Items.Add("1");
            drpclientgroup.SelectedValue = "1";
            _accountsHomePagePrivate.SetField("drpclientgroup", drpclientgroup);
            ShimFormsAuthentication.SignOut = () => { };
            ShimFormsAuthentication.SetAuthCookieStringBoolean = (p1, p2) => { };
            ShimCustomer.GetByClientIDInt32Boolean             = (p1, p2) => new Customer {
            };
            var cookies = new HttpCookieCollection();

            ShimHttpResponse.AllInstances.CookiesGet = (p) => cookies;
            ShimFormsAuthentication.EncryptFormsAuthenticationTicket = (p) => "test";

            // Act
            _accountsHomePagePrivate.Invoke("drpAccount_SelectedIndexChanged", new object[] { null, null });

            // Assert
            _accountsHomePagePrivate.ShouldSatisfyAllConditions(
                () => _redirectUrl.ShouldBe("~/Default.aspx"),
                () => cookies[FormsAuthentication.FormsCookieName].ShouldNotBeNull(),
                () => cookies[FormsAuthentication.FormsCookieName].Value.ShouldBe("test"));
        }
Ejemplo n.º 2
0
        public void DrpAccount_SelectedIndexChanged_CreateCookie_Redirect()
        {
            // Arrange
            InitializeAuthTests();

            _drpClient.Items.Add("1");
            _drpClient.SelectedValue = "1";

            ShimFormsAuthentication.SignOut = () => { };
            ShimFormsAuthentication.SetAuthCookieStringBoolean = (p1, p2) => { };
            ShimCustomer.GetByClientIDInt32Boolean             = (p1, p2) => new Customer {
            };
            var cookies = new HttpCookieCollection();

            ShimHttpResponse.AllInstances.CookiesGet = (p) => cookies;
            ShimFormsAuthentication.EncryptFormsAuthenticationTicket = (p) => p.UserData;

            // Act
            _communicatorPrivateObject.Invoke("drpAccount_SelectedIndexChanged", new object[] { null, null });

            // Assert
            _communicatorPrivateObject.ShouldSatisfyAllConditions(
                () => _redirectUrl.ShouldBe("~/Default.aspx"),
                () => cookies[FormsAuthentication.FormsCookieName].ShouldNotBeNull(),
                () => cookies[FormsAuthentication.FormsCookieName].Value.ShouldBe("-1,,5,1,00000000-0000-0000-0000-000000000000"));
        }