public void ExecuteGetSuccessfulWithResultsFromJSONFile() { //Arrange var segmentCache = new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>()); var segmentFetcher = new JSONFileSegmentFetcher($"{rootFilePath}segment_payed.json", segmentCache); //Act segmentFetcher.InitializeSegment("payed"); //Assert Assert.IsTrue(segmentCache.IsInSegment("payed", "abcdz")); }
public JSONFileClient(string splitsFilePath, string segmentsFilePath, ISplitLogger log = null, ISegmentCache segmentCacheInstance = null, ISplitCache splitCacheInstance = null, IImpressionsLog impressionsLog = null, bool isLabelsEnabled = true, IEventsLog eventsLog = null, ITrafficTypeValidator trafficTypeValidator = null, IImpressionsManager impressionsManager = null) : base(GetLogger(log)) { _segmentCache = segmentCacheInstance ?? new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>()); var segmentFetcher = new JSONFileSegmentFetcher(segmentsFilePath, _segmentCache); var splitChangeFetcher = new JSONFileSplitChangeFetcher(splitsFilePath); var task = splitChangeFetcher.Fetch(-1); task.Wait(); var splitChangesResult = task.Result; var parsedSplits = new ConcurrentDictionary <string, ParsedSplit>(); _splitParser = new InMemorySplitParser(segmentFetcher, _segmentCache); foreach (var split in splitChangesResult.splits) { parsedSplits.TryAdd(split.name, _splitParser.Parse(split)); } _splitCache = splitCacheInstance ?? new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(parsedSplits)); _impressionsLog = impressionsLog; LabelsEnabled = isLabelsEnabled; _eventsLog = eventsLog; _trafficTypeValidator = trafficTypeValidator; _blockUntilReadyService = new NoopBlockUntilReadyService(); _manager = new SplitManager(_splitCache, _blockUntilReadyService, log); ApiKey = "localhost"; BuildEvaluator(log); _impressionsManager = impressionsManager ?? new ImpressionsManager(impressionsLog, null, null, false, ImpressionsMode.Debug); }
public JSONFileClient(string splitsFilePath, string segmentsFilePath, ISegmentCache segmentCacheInstance = null, ISplitCache splitCacheInstance = null, IImpressionListener treatmentLogInstance = null, bool isLabelsEnabled = true) { segmentCache = segmentCacheInstance ?? new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>()); var segmentFetcher = new JSONFileSegmentFetcher(segmentsFilePath, segmentCache); var splitParser = new InMemorySplitParser(segmentFetcher, segmentCache); var splitChangeFetcher = new JSONFileSplitChangeFetcher(splitsFilePath); var splitChangesResult = splitChangeFetcher.Fetch(-1); var parsedSplits = new ConcurrentDictionary <string, ParsedSplit>(); foreach (Split split in splitChangesResult.splits) { parsedSplits.TryAdd(split.name, splitParser.Parse(split)); } splitCache = splitCacheInstance ?? new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(parsedSplits)); impressionListener = treatmentLogInstance; splitter = new Splitter(); LabelsEnabled = isLabelsEnabled; manager = new SplitManager(splitCache); }
public JSONFileClient(string splitsFilePath, string segmentsFilePath, ILog log, ISegmentCache segmentCacheInstance = null, ISplitCache splitCacheInstance = null, IListener <KeyImpression> treatmentLogInstance = null, bool isLabelsEnabled = true, IListener <WrappedEvent> _eventListener = null, ITrafficTypeValidator trafficTypeValidator = null) : base(log) { segmentCache = segmentCacheInstance ?? new InMemorySegmentCache(new ConcurrentDictionary <string, Segment>()); var segmentFetcher = new JSONFileSegmentFetcher(segmentsFilePath, segmentCache); var splitParser = new InMemorySplitParser(segmentFetcher, segmentCache); var splitChangeFetcher = new JSONFileSplitChangeFetcher(splitsFilePath); var task = splitChangeFetcher.Fetch(-1); task.Wait(); var splitChangesResult = task.Result; var parsedSplits = new ConcurrentDictionary <string, ParsedSplit>(); foreach (Split split in splitChangesResult.splits) { parsedSplits.TryAdd(split.name, splitParser.Parse(split)); } splitCache = splitCacheInstance ?? new InMemorySplitCache(new ConcurrentDictionary <string, ParsedSplit>(parsedSplits)); impressionListener = treatmentLogInstance; splitter = new Splitter(); LabelsEnabled = isLabelsEnabled; eventListener = _eventListener; _trafficTypeValidator = trafficTypeValidator; _blockUntilReadyService = new NoopBlockUntilReadyService(); manager = new SplitManager(splitCache, _blockUntilReadyService, log); ApiKey = "localhost"; }