Пример #1
0
            public void DeserializesWhenCookieIsPresentAndValid()
            {
                RequestCookies.Add(new HttpCookie(CookieName, SerializedEnrollment));

                var result = RunTest(User);

                Assert.True(result, "The test should be enabled.");
                Assert.Empty(ResponseCookies.Keys.Cast <string>());
                EnrollmentFactory.Verify(x => x.Initialize(), Times.Never);
                EnrollmentFactory.Verify(x => x.Serialize(It.IsAny <ABTestEnrollment>()), Times.Never);
                EnrollmentFactory.Verify(x => x.TryDeserialize(It.IsAny <string>(), out OutEnrollment), Times.Once);
            }
Пример #2
0
            public void InitializesWhenCookieIsPresentAndInvalid()
            {
                RequestCookies.Add(new HttpCookie(CookieName, SerializedEnrollment));
                EnrollmentFactory
                .Setup(x => x.TryDeserialize(It.IsAny <string>(), out OutEnrollment))
                .Returns(false);

                var result = RunTest(User);

                Assert.True(result, "The test should be enabled.");
                Assert.Contains(CookieName, ResponseCookies.Keys.Cast <string>());
                var cookie = ResponseCookies[CookieName];

                VerifyCookie(cookie);
                EnrollmentFactory.Verify(x => x.Initialize(), Times.Once);
                EnrollmentFactory.Verify(x => x.Serialize(InitializedEnrollment), Times.Once);
                EnrollmentFactory.Verify(x => x.Serialize(It.IsAny <ABTestEnrollment>()), Times.Once);
                EnrollmentFactory.Verify(x => x.TryDeserialize(It.IsAny <string>(), out OutEnrollment), Times.Once);
            }