public void ParseSuccessfullyWhenMurmurAlgorithm() { //Arrange Split split = new Split(); split.name = "test1"; split.seed = 2323; split.status = "ACTIVE"; split.killed = false; split.defaultTreatment = "off"; split.changeNumber = 232323; split.algo = 2; split.trafficTypeName = "user"; split.conditions = new List <ConditionDefinition>(); var parser = new InMemorySplitParser(null, null); //Act var parsedSplit = parser.Parse(split); //Assert Assert.IsNotNull(parsedSplit); Assert.AreEqual(split.name, parsedSplit.name); Assert.AreEqual(split.seed, parsedSplit.seed); Assert.AreEqual(split.killed, parsedSplit.killed); Assert.AreEqual(split.defaultTreatment, parsedSplit.defaultTreatment); Assert.AreEqual(split.changeNumber, parsedSplit.changeNumber); Assert.AreEqual(AlgorithmEnum.Murmur, parsedSplit.algo); Assert.AreEqual(split.trafficTypeName, parsedSplit.trafficTypeName); }
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"; }