public void Init() { _blockedHttpHeaders = new List <string>() { }; _includedQueryStringParameters = new List <string>(); _aspSessionCookieName = Engines.Constants.DEFAULT_ASP_COOKIE_NAME; _interval = new TimeSpan(0, 0, 0, 0, 50); _evidenceKeyFilter = new EvidenceKeyFilterShareUsage( _blockedHttpHeaders, _includedQueryStringParameters, true, _aspSessionCookieName); _shareUsageTracker = new ShareUsageTracker(new CacheConfiguration() { Builder = new LruPutCacheBuilder(), Size = 1000 }, _interval, _evidenceKeyFilter); _evidenceData = new Dictionary <string, object>() { { Core.Constants.EVIDENCE_HTTPHEADER_PREFIX + Core.Constants.EVIDENCE_SEPERATOR + "user-agent", "iPhone" } }; var dataKeyBuilder = new DataKeyBuilder(); foreach (var evidence in _evidenceData) { dataKeyBuilder.Add(100, evidence.Key, evidence.Value); } _data = MockFlowData.CreateFromEvidence(_evidenceData, false); _data.Setup(d => d.GenerateKey(It.IsAny <IEvidenceKeyFilter>())).Returns(dataKeyBuilder.Build()); }
public void ShareUsageTracker_Session_DoNotTrack() { var evidenceKeyFilter = new EvidenceKeyFilterShareUsage( _blockedHttpHeaders, _includedQueryStringParameters, false, _aspSessionCookieName); var shareUsageTracker = new ShareUsageTracker(new CacheConfiguration() { Builder = new LruPutCacheBuilder(), Size = 1000 }, _interval, evidenceKeyFilter); int trackedEvents = 0; for (var i = 0; i < 2; i++) { var evidenceData = new Dictionary <string, object>() { { Core.Constants.EVIDENCE_HTTPHEADER_PREFIX + Core.Constants.EVIDENCE_SEPERATOR + "user-agent", "iPhone" }, { Core.Constants.EVIDENCE_COOKIE_PREFIX + Core.Constants.EVIDENCE_SEPERATOR + Engines.Constants.DEFAULT_ASP_COOKIE_NAME, i } }; var data = MockFlowData.CreateFromEvidence(_evidenceData, true); data.Setup(d => d.GenerateKey(It.IsAny <IEvidenceKeyFilter>())).Returns( (IEvidenceKeyFilter filter) => { return(GenerateKey(filter, evidenceData)); }); if (shareUsageTracker.Track(data.Object)) { trackedEvents++; } } Assert.IsTrue(trackedEvents == 1); }