public void GetCurrentIntervalQueriesRanCount_ShouldReturnZero_WhenAllPending() { var queryQueue = new QueryQueue(); var query1 = new TestQuery(1, QueryFunctionType.SingleQuote); var query2 = new TestQuery(2, QueryFunctionType.IntraDay); var query3 = new TestQuery(3, QueryFunctionType.Weekly); queryQueue.Enqueue(query1); queryQueue.Enqueue(query2); queryQueue.Enqueue(query3); Assert.Equal(0, queryQueue.GetCurrentIntervalQueriesRanCount()); }
public async Task GetCurrentIntervalQueriesRanCount_ShouldResetOnNextInterval() { var queryQueue = new QueryQueue(); queryQueue.SetIntervalKey(() => DateTime.UtcNow.Millisecond); var query1 = new TestQuery(1, QueryFunctionType.SingleQuote); var query2 = new TestQuery(2, QueryFunctionType.IntraDay); var query3 = new TestQuery(3, QueryFunctionType.Weekly); queryQueue.Enqueue(query1); queryQueue.Enqueue(query2); queryQueue.Enqueue(query3); queryQueue.Dequeue(2); queryQueue.MarkAsExecuted(query1); queryQueue.MarkAsExecuted(query2); Assert.Equal(2, queryQueue.GetCurrentIntervalQueriesRanCount()); await Task.Delay(10); Assert.Equal(0, queryQueue.GetCurrentIntervalQueriesRanCount()); }
public void GetCurrentIntervalQueriesRanCount_ShouldReturnExecutedAndExecutingQueryCount() { var queryQueue = new QueryQueue(); var query1 = new TestQuery(1, QueryFunctionType.SingleQuote); var query2 = new TestQuery(2, QueryFunctionType.IntraDay); var query3 = new TestQuery(3, QueryFunctionType.Weekly); queryQueue.Enqueue(query1); queryQueue.Enqueue(query2); queryQueue.Enqueue(query3); queryQueue.Dequeue(3); queryQueue.MarkAsExecuted(query1); queryQueue.MarkAsExecuted(query2); Assert.Equal(3, queryQueue.GetCurrentIntervalQueriesRanCount()); }