public void ThrowStorageExceptionInDeleteLogsTime()
        {
            var log = new TestLog();
            var storageException = new StorageException();

            // Make sure that the storage exception is "observed" to
            // avoid the exception propagating to the point where the
            // test fails.
            TaskScheduler.UnobservedTaskException += (sender, e) =>
            {
                if (e.Exception.InnerException == storageException)
                {
                    e.SetObserved();
                }
            };
            var storage = new Mock <IStorage>();

            storage.Setup(s => s.DeleteLogs(It.IsAny <string>(), It.IsAny <string>())).Throws(storageException);
            storage.Setup(s => s.GetLogsAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <List <Log> >()))
            .Callback((string channelName, int limit, List <Log> logs) => logs.Add(log))
            .Returns(() => Task.FromResult("test-batch-id"));

            _channel = new Microsoft.AppCenter.Channel.Channel(ChannelName, 1, _batchTimeSpan, 1, _appSecret, _mockIngestion, storage.Object);
            SetupEventCallbacks();

            // Shutdown channel and store some log
            _channel.ShutdownAsync().RunNotAsync();
            _channel.EnqueueAsync(log).RunNotAsync();

            _channel.SetEnabled(true);

            Assert.IsTrue(SentLogOccurred(1));

            // Not throw any exception
        }
예제 #2
0
 private void SetChannelWithTimeSpan(TimeSpan timeSpan)
 {
     _storage = new MockStorage();
     _channel = new Microsoft.AppCenter.Channel.Channel(ChannelName, MaxLogsPerBatch, timeSpan, MaxParallelBatches,
                                                        _appSecret, _mockIngestion, _storage);
     MakeIngestionCallsSucceed();
     SetupEventCallbacks();
 }
 private void SetChannelWithTimeSpan(TimeSpan timeSpan)
 {
     if (TestContext.TestName != "ThrowStorageExceptionInDeleteLogsTime")
     {
         _storage = new MockStorage();
         _channel = new Microsoft.AppCenter.Channel.Channel(ChannelName, MaxLogsPerBatch, timeSpan, MaxParallelBatches,
                                                            _appSecret, _mockIngestion, _storage);
         SetupEventCallbacks();
     }
     MakeIngestionCallsSucceed();
 }
예제 #4
0
        public void ThrowStorageExceptionInDeleteLogsTime()
        {
            var storage = new Mock <IStorage>();

            storage.Setup(s => s.DeleteLogs(It.IsAny <string>(), It.IsAny <string>())).Throws <StorageException>();
            storage.Setup(s => s.GetLogsAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <List <Log> >())).Returns(Task.FromResult(""));

            Microsoft.AppCenter.Channel.Channel channel = new Microsoft.AppCenter.Channel.Channel("name", 1, _batchTimeSpan, 1, _appSecret, _mockIngestion, storage.Object);

            // Shutdown channel and store some log
            channel.ShutdownAsync().RunNotAsync();
            channel.EnqueueAsync(new TestLog()).RunNotAsync();

            channel.SetEnabled(true);

            // Not throw any exception
        }