public void IsVisitorInSegment_throws_ArgumentNullException_when_segment_is_null() { var sut = new CookieTrackingDataSource(() => null); Action test = () => sut.IsVisitorInSegment("visitorId", null); Assert.Throws <ArgumentNullException>(test); }
public void IsVisitorInSegment_is_true_when_segment_has_cookie(string segmentAlias, bool expected) { var httpRequestBaseMock = new Mock <HttpRequestBase>(); httpRequestBaseMock.Setup(x => x.Cookies) .Returns(new HttpCookieCollection { new HttpCookie(string.Format(CookieTrackingDataSource.CookieNameFormat, "facebook")), new HttpCookie(string.Format(CookieTrackingDataSource.CookieNameFormat, "customer")), new HttpCookie(string.Format(CookieTrackingDataSource.CookieNameFormat, "new")) }); var httpContextBaseMock = new Mock <HttpContextBase>(); httpContextBaseMock.Setup(x => x.Request).Returns(httpRequestBaseMock.Object); var sut = new CookieTrackingDataSource(() => httpContextBaseMock.Object); var actual = sut.IsVisitorInSegment("visitorId", new Segment { Alias = segmentAlias }); Assert.Equal(expected, actual); }