示例#1
0
        public void GetLogsQueryError()
        {
            var mockAdapter = new Mock <IStorageAdapter>();

            mockAdapter.Setup(
                a => a.GetAsync(It.IsAny <PredType>(), It.IsAny <int>()))
            .Returns(TaskExtension.GetFaultedTask <List <Microsoft.AppCenter.Storage.Storage.LogEntry> >(new StorageException()));
            var fakeStorage = new Microsoft.AppCenter.Storage.Storage(mockAdapter.Object);
            var logs        = new List <Log>();

            Assert.ThrowsException <StorageException>(() =>
                                                      fakeStorage.GetLogsAsync(StorageTestChannelName, 1, logs).RunNotAsync());
        }
示例#2
0
        public void StorageThrowsStorageException()
        {
            var mockAdapter = new Mock <IStorageAdapter>();

            mockAdapter.Setup(
                a => a.GetAsync(It.IsAny <PredType>(), It.IsAny <int>()))
            .Returns(TaskExtension.GetFaultedTask <List <Microsoft.AppCenter.Storage.Storage.LogEntry> >(new StorageException()));
            mockAdapter.Setup(c => c.InsertAsync(It.IsAny <Microsoft.AppCenter.Storage.Storage.LogEntry>()))
            .Returns(TaskExtension.GetFaultedTask <int>(new StorageException()));
            mockAdapter.Setup(c => c.DeleteAsync(It.IsAny <Expression <Func <Microsoft.AppCenter.Storage.Storage.LogEntry, bool> > >()))
            .Returns(TaskExtension.GetFaultedTask <int>(new StorageException()));
            mockAdapter.Setup(c => c.CountAsync(It.IsAny <Expression <Func <Microsoft.AppCenter.Storage.Storage.LogEntry, bool> > >()))
            .Returns(TaskExtension.GetFaultedTask <int>(new StorageException()));
            var fakeStorage = new Microsoft.AppCenter.Storage.Storage(mockAdapter.Object);

            Assert.ThrowsException <StorageException>(() => fakeStorage.PutLog("channel_name", new TestLog()).RunNotAsync());
            Assert.ThrowsException <StorageException>(() => fakeStorage.DeleteLogs("channel_name", string.Empty).RunNotAsync());
            Assert.ThrowsException <StorageException>(() => fakeStorage.CountLogsAsync("channel_name").RunNotAsync());
            Assert.ThrowsException <StorageException>(() => fakeStorage.GetLogsAsync("channel_name", 1, new List <Log>()).RunNotAsync());
        }
示例#3
0
 public Task ExecuteCallAsync(IServiceCall call)
 {
     return(CallShouldSucceed ? TaskExtension.GetCompletedTask() : TaskExtension.GetFaultedTask(TaskError));
 }