public async Task Delegates_CallsRelease_OnFailure() { string token = Guid.NewGuid().ToString(); bool called = false; ChangeFeedProcessorHealthMonitorCore monitor = new ChangeFeedProcessorHealthMonitorCore(); monitor.SetLeaseReleaseDelegate((string leaseToken) => { called = true; Assert.AreEqual(token, leaseToken); throw new Exception("Should not fail process"); }); await monitor.NotifyLeaseReleaseAsync(token); Assert.IsTrue(called); }
public async Task Delegates_CallsRelease() { string token = Guid.NewGuid().ToString(); bool called = false; ChangeFeedProcessorHealthMonitorCore monitor = new ChangeFeedProcessorHealthMonitorCore(); monitor.SetLeaseReleaseDelegate((string leaseToken) => { called = true; Assert.AreEqual(token, leaseToken); return(Task.CompletedTask); }); await monitor.NotifyLeaseReleaseAsync(token); Assert.IsTrue(called); }
public async Task Delegates_CallsError() { Exception ex = new Exception(); string token = Guid.NewGuid().ToString(); bool called = false; ChangeFeedProcessorHealthMonitorCore monitor = new ChangeFeedProcessorHealthMonitorCore(); monitor.SetErrorDelegate((string leaseToken, Exception exception) => { called = true; Assert.AreEqual(token, leaseToken); Assert.ReferenceEquals(ex, exception); return(Task.CompletedTask); }); await monitor.NotifyErrorAsync(token, ex); Assert.IsTrue(called); }