public async Task FailWithNonStorageError() { var func = MockCloudTable.GetSafeCreateMethod(); // Completely different exception Storage error var exception = new InvalidOperationException("other"); try { var table = new MockCloudTable(); table.Func = new Action[] { () => { throw exception; } // terminal abort }; await func(table); Assert.True(false); // should have thrown } catch (Exception e) { Assert.True(object.ReferenceEquals(e, exception)); } }
public async Task CreateNormal() { var func = MockCloudTable.GetSafeCreateMethod(); var table = new MockCloudTable(); table.Func = new Action[] { () => { } // Nop, success }; await func(table); }
public async Task CreateWithConflict() { var func = MockCloudTable.GetSafeCreateMethod(); { var table = new MockCloudTable(); table.Func = new Action[] { () => { throw Error(HttpStatusCode.Conflict); }, () => { }, // success }; await func(table); } }
public async Task FailWithStorageError() { var func = MockCloudTable.GetSafeCreateMethod(); var exception = Error(HttpStatusCode.BadRequest); try { var table = new MockCloudTable(); table.Func = new Action[] { () => { throw exception; } // terminal abort }; await func(table); Assert.True(false); // should have thrown } catch (StorageException e) { Assert.True(object.ReferenceEquals(e, exception)); } }
public async Task FailWithTimeout() { var func = MockCloudTable.GetSafeCreateMethod(); try { var table = new MockCloudTable(); table.Func = new Action[] { () => { throw Error(HttpStatusCode.Conflict); }, () => { throw Error(HttpStatusCode.Conflict); }, () => { throw Error(HttpStatusCode.Conflict); }, () => { throw Error(HttpStatusCode.Conflict); }, }; await func(table); Assert.True(false); // should have thrown } catch (StorageException) { // Success } }