public QueryMultiAnalysisIntervalAsync ( string collection, IEnumerable |
||
collection | string | Name of event collection to query. |
analysisParams | IEnumerable |
Defines the multiple types of analyses to perform. |
timeframe | QueryTimeframe | Specifies window of time from which to select events for analysis. May be absolute or relative. |
interval | Keen.Core.Query.QueryInterval | The block size for partitioning the specified timeframe. Optional, may be null. |
filters | IEnumerable |
Filters to narrow down the events used in analysis. Optional, may be null. |
timezone | string | The timezone to use when specifying a relative timeframe. Optional, may be blank. |
return | string>>>>.Task |
public async void MultiAnalysis_ValidInterval_Success() { var client = new KeenClient(settingsEnv); IEnumerable<MultiAnalysisParam> param = new List<MultiAnalysisParam>() { new MultiAnalysisParam("first", MultiAnalysisParam.Metric.Count()), new MultiAnalysisParam("second", MultiAnalysisParam.Metric.Maximum("field1")), new MultiAnalysisParam("third", MultiAnalysisParam.Metric.Minimum("field1")), }; var timeframe = QueryRelativeTimeframe.PreviousNDays(3); var interval = QueryInterval.Daily(); IEnumerable<QueryIntervalValue<IDictionary<string, string>>> result = new List<QueryIntervalValue<IDictionary<string, string>>>(); foreach( var i in Enumerable.Range(1,3)) { var dic = new Dictionary<string, string>(); dic.Add("second", "fff"); dic.Add("third", "aaa"); dic.Add("first", "123"); var qv = new QueryIntervalValue<IDictionary<string,string>>(dic, DateTime.Now, DateTime.Now.AddSeconds(2)); ((List<QueryIntervalValue<IDictionary<string, string>>>)result).Add(qv); } Mock<IQueries> queryMock = null; if (UseMocks) { queryMock = new Mock<IQueries>(); queryMock.Setup(m => m.MultiAnalysis( It.Is<string>(c => c == testCol), It.Is<IEnumerable<MultiAnalysisParam>>(p => p == param), It.Is<QueryTimeframe>(t => t == timeframe), It.Is<QueryInterval>(i => i == interval), It.Is<IEnumerable<QueryFilter>>(f => f == null), It.Is<string>(tz => tz == "") )) .Returns(Task.FromResult(result)); client.Queries = queryMock.Object; } var reply = (await client.QueryMultiAnalysisIntervalAsync(testCol, param, timeframe, interval)).ToList(); if (null != queryMock) { queryMock.VerifyAll(); Assert.AreEqual(reply.Count(), result.Count()); } }