public void ThrowsAnExceptionWhenStartedBeforeInitialized() { cancellationSourceFactory.Setup(o => o.Create(It.IsAny <CancellationToken>())).Returns(cancellationSource.Object); using var target = new StubProducerEngine(cancellationSourceFactory.Object); Assert.ThrowsAsync <EngineException>(async() => await target.StartAsync()); }
public void ThrowsAnExceptionWhenWaitingBeforeStarted() { cancellationSourceFactory.Setup(o => o.Create(It.IsAny <CancellationToken>())).Returns(cancellationSource.Object); using var target = new StubProducerEngine(cancellationSourceFactory.Object); target.Initialize(context => { }, CancellationToken.None); Assert.ThrowsAsync <EngineException>(async() => await target.WaitForCompletionAsync()); }
public void ThrowsAnExceptionWhenInitializedTwice() { cancellationSourceFactory.Setup(o => o.Create(It.IsAny <CancellationToken>())).Returns(cancellationSource.Object); using var target = new StubProducerEngine(cancellationSourceFactory.Object); target.Initialize(context => { }, CancellationToken.None); Assert.Throws <EngineException>(() => target.Initialize(context => { }, CancellationToken.None)); }
public void ThrowsAnExceptionWhenCancellationSourceIsNull() { using var target = new StubProducerEngine(cancellationSourceFactory.Object); Assert.Throws <InvalidOperationException>(() => target.Initialize(context => { }, CancellationToken.None)); }
public void ThrowsAnExceptionWhenCallbackIsNull() { using var target = new StubProducerEngine(cancellationSourceFactory.Object); Assert.Throws <ArgumentNullException>(() => target.Initialize(null, CancellationToken.None)); }