Пример #1
0
        public void ShutdownPreventsNewTasks()
        {
            var mockConnection = new Mock <IStorageAdapter>();
            var storage        = new Microsoft.AppCenter.Storage.Storage(mockConnection.Object);
            var result         = storage.ShutdownAsync(TimeSpan.FromSeconds(10)).RunNotAsync();

            Assert.IsTrue(result);
            Assert.ThrowsException <StorageException>(
                () => storage.GetLogsAsync(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <List <Log> >()).RunNotAsync());
        }
Пример #2
0
        public void ShutdownSucceed()
        {
            var mockConnection = new Mock <IStorageAdapter>();

            mockConnection.Setup(
                c => c.Insert(TableName, It.IsAny <string[]>(), It.IsAny <List <object[]> >()))
            .Callback(() => Task.Delay(TimeSpan.FromSeconds(2)).Wait());
            var storage = new Microsoft.AppCenter.Storage.Storage(mockConnection.Object, It.IsAny <string>());

            // Ignore warnings because we just want to "fire and forget"
#pragma warning disable 4014
            storage.PutLog(StorageTestChannelName, new TestLog());
            storage.PutLog(StorageTestChannelName, new TestLog());
#pragma warning restore 4014

            var result = storage.ShutdownAsync(TimeSpan.FromSeconds(100)).RunNotAsync();
            Assert.IsTrue(result);
        }
Пример #3
0
        public void ShutdownTimeout()
        {
            var mockConnection = new Mock <IStorageAdapter>();

            mockConnection.Setup(
                c => c.InsertAsync(It.IsAny <Microsoft.AppCenter.Storage.Storage.LogEntry>()))
            .Callback(() => Task.Delay(TimeSpan.FromDays(1)).Wait())
            .Returns(TaskExtension.GetCompletedTask(1));
            var storage = new Microsoft.AppCenter.Storage.Storage(mockConnection.Object);

            // Ignore warnings because we just want to "fire and forget"
#pragma warning disable 4014
            storage.PutLog(StorageTestChannelName, new TestLog());
            storage.PutLog(StorageTestChannelName, new TestLog());
#pragma warning restore 4014

            var result = storage.ShutdownAsync(TimeSpan.FromTicks(1)).RunNotAsync();
            Assert.IsFalse(result);
        }