コード例 #1
0
 public Task ClearPendingLogState(string channelName)
 {
     lock (this)
     {
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #2
0
 public Task WaitOperationsAsync(TimeSpan timeout)
 {
     lock (this)
     {
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #3
0
 public Task <int> CountLogsAsync(string channelName)
 {
     lock (this)
     {
         return(TaskExtension.GetCompletedTask(this[channelName].Count));
     }
 }
コード例 #4
0
 public Task <bool> SetMaxStorageSizeAsync(long sizeInBytes)
 {
     lock (this)
     {
         return(TaskExtension.GetCompletedTask(true));
     }
 }
コード例 #5
0
 public Task <bool> ShutdownAsync(TimeSpan timeout)
 {
     lock (this)
     {
         return(TaskExtension.GetCompletedTask(true));
     }
 }
コード例 #6
0
 public Task DeleteLogs(string channelName)
 {
     lock (this)
     {
         _storage.Remove(channelName);
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #7
0
 public Task PutLog(string channelName, Log log)
 {
     lock (this)
     {
         this[channelName].Add(log);
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #8
0
ファイル: MockStorage.cs プロジェクト: nor0x/AppCenter-XMac
 public Task DeleteLogs(string channelName)
 {
     lock (this)
     {
         AppCenterLog.Debug(AppCenterLog.LogTag, $"Storage.DeleteLogs for channelName={channelName}");
         _storage.Remove(channelName);
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #9
0
ファイル: MockStorage.cs プロジェクト: nor0x/AppCenter-XMac
 public Task PutLog(string channelName, Log log)
 {
     lock (this)
     {
         AppCenterLog.Debug(AppCenterLog.LogTag, $"Storage.PutLog for channelName={channelName}: {log}");
         this[channelName].Add(log);
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #10
0
 public Task DeleteLogs(string channelName, string batchId)
 {
     lock (this)
     {
         var batch = _pending[batchId];
         this[channelName].RemoveAll(log => batch.Contains(log));
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #11
0
ファイル: MockStorage.cs プロジェクト: nor0x/AppCenter-XMac
 public Task DeleteLogs(string channelName, string batchId)
 {
     lock (this)
     {
         AppCenterLog.Debug(AppCenterLog.LogTag, $"Storage.DeleteLogs for channelName={channelName} and batchId={batchId}");
         var batch = _pending[batchId];
         this[channelName].RemoveAll(log => batch.Contains(log));
         return(TaskExtension.GetCompletedTask());
     }
 }
コード例 #12
0
 public Task <string> GetLogsAsync(string channelName, int limit, List <Log> logs)
 {
     lock (this)
     {
         var batchId = Guid.NewGuid().ToString();
         var batch   = this[channelName].Take(limit).ToList();
         _pending.Add(batchId, batch);
         logs?.Clear();
         logs?.AddRange(batch);
         return(TaskExtension.GetCompletedTask(batchId));
     }
 }
コード例 #13
0
 public Task <string> GetLogsAsync(string channelName, int limit, List <Log> logs)
 {
     lock (this)
     {
         var pending = _pending.SelectMany(i => i.Value).ToList();
         var batchId = Guid.NewGuid().ToString();
         var batch   = this[channelName]
                       .Where(log => !pending.Contains(log))
                       .Take(limit).ToList();
         _pending.Add(batchId, batch);
         logs?.Clear();
         logs?.AddRange(batch);
         return(TaskExtension.GetCompletedTask(batchId));
     }
 }
コード例 #14
0
ファイル: MockStorage.cs プロジェクト: nor0x/AppCenter-XMac
 public Task <string> GetLogsAsync(string channelName, int limit, List <Log> logs)
 {
     lock (this)
     {
         var pending = _pending.SelectMany(i => i.Value).ToList();
         var batchId = Guid.NewGuid().ToString();
         var batch   = this[channelName]
                       .Where(log => !pending.Contains(log))
                       .Take(limit).ToList();
         if (batch.Count == 0)
         {
             return(TaskExtension.GetCompletedTask <string>(null));
         }
         _pending.Add(batchId, batch);
         logs?.Clear();
         logs?.AddRange(batch);
         AppCenterLog.Debug(AppCenterLog.LogTag, $"Storage.GetLogsAsync for channelName={channelName}: batchId={batchId} with logs={string.Join(",", logs)}");
         return(TaskExtension.GetCompletedTask(batchId));
     }
 }
コード例 #15
0
        /// <summary>
        /// Helper for setup responce.
        /// </summary>
        protected ISetup <IHttpNetworkAdapter, Task <string> > SetupAdapterSendResponse(params HttpStatusCode[] statusCodes)
        {
            var index = 0;
            var setup = _adapter
                        .Setup(a => a.SendAsync(
                                   It.IsAny <string>(),
                                   "POST",
                                   It.IsAny <IDictionary <string, string> >(),
                                   It.IsAny <string>(),
                                   It.IsAny <CancellationToken>()));

            setup.Returns(() =>
            {
                var statusCode = statusCodes[index < statusCodes.Length ? index++ : statusCodes.Length - 1];
                return(statusCode == HttpStatusCode.OK
                    ? TaskExtension.GetCompletedTask("")
                    : TaskExtension.GetFaultedTask <string>(new HttpIngestionException("")
                {
                    StatusCode = (int)statusCode
                }));
            });
            return(setup);
        }
コード例 #16
0
 public Task ClearPendingLogStateAsync(string channelName)
 {
     return(TaskExtension.GetCompletedTask());
 }
コード例 #17
0
 public Task DeleteLogsAsync(string channelName)
 {
     return(TaskExtension.GetCompletedTask());
 }
コード例 #18
0
 public Task <int> CountLogsAsync(string channelName)
 {
     return(TaskExtension.GetCompletedTask(1));
 }
コード例 #19
0
 public Task DeleteLogs(string channelName, string batchId)
 {
     return(TaskExtension.GetCompletedTask());
 }
コード例 #20
0
 public Task <string> GetLogsAsync(string channelName, int limit, List <Log> logs)
 {
     return(TaskExtension.GetCompletedTask(Guid.NewGuid().ToString()));
 }
コード例 #21
0
 public Task PutLog(string channelName, Log log)
 {
     return(TaskExtension.GetCompletedTask());
 }