public void CancelQueueCookie_Test()
        {
            var eventId      = "event1";
            var cookieDomain = "testDomain";

            var cookieKey    = UserInQueueStateCookieRepository.GetCookieKey(eventId);
            var fakeContext  = MockRepository.GenerateMock <HttpContextBase>();
            var fakeResponse = MockRepository.GenerateMock <HttpResponseBase>();

            fakeContext.Stub(stub => stub.Response).Return(fakeResponse);
            var cookies = new HttpCookieCollection()
            {
                new HttpCookie("a")
                {
                    Value = "test"
                },
                new HttpCookie("b")
                {
                    Value = "test"
                }
            };

            fakeResponse.Stub(stub => stub.Cookies).Return(cookies);

            var testObject = new UserInQueueStateCookieRepository(fakeContext);

            testObject.CancelQueueCookie(eventId, cookieDomain);
            Assert.True(cookies[cookieKey].Expires.Subtract(DateTime.UtcNow.AddDays(-1)) < TimeSpan.FromMinutes(1));
            Assert.True(cookies[cookieKey].Domain == cookieDomain);
        }
Пример #2
0
        public void CancelQueueCookie_CookieDoesNotExist_Test()
        {
            var eventId     = "event1";
            var cookieKey   = UserInQueueStateCookieRepository.GetCookieKey(eventId);
            var fakeContext = MockRepository.GenerateMock <HttpContextBase>();

            var fakeResponse = MockRepository.GenerateMock <HttpResponseBase>();

            fakeContext.Stub(stub => stub.Response).Return(fakeResponse);
            var cookies = new HttpCookieCollection()
            {
                new HttpCookie("a")
                {
                    Value = "test"
                },
                new HttpCookie("b")
                {
                    Value = "test"
                }
            };

            fakeResponse.Stub(stub => stub.Cookies).Return(cookies);

            var testObject = new UserInQueueStateCookieRepository(fakeContext);


            testObject.CancelQueueCookie(eventId);
            Assert.True(cookies[cookieKey] == null);
        }
        public void CancelQueueCookie_Test()
        {
            var eventId      = "event1";
            var cookieDomain = "testDomain";

            var cookieKey = UserInQueueStateCookieRepository.GetCookieKey(eventId);

            KnownUserTest.HttpContextMock fakeContext = new KnownUserTest.HttpContextMock();
            var fakeResponse = new KnownUserTest.MockHttpResponse()
            {
            };

            fakeContext.HttpResponse = fakeResponse;
            var testObject = new UserInQueueStateCookieRepository(fakeContext);

            testObject.CancelQueueCookie(eventId, cookieDomain);
            Assert.True(((DateTime)fakeResponse.CookiesValue[cookieKey]["expiration"]).Subtract(DateTime.UtcNow.AddDays(-1)) < TimeSpan.FromMinutes(1));
            Assert.True(fakeResponse.CookiesValue[cookieKey]["domain"].ToString() == cookieDomain);
        }