public IAsyncEnumerable <TResponse> CreateStream <TResponse>( IStreamRequest <TResponse> request, CancellationToken cancellationToken = default) { var cancellationTokenToUse = GetCustomOrDefaultCancellationToken(cancellationToken); return(_mediator.CreateStream(request, cancellationTokenToUse)); }
public async Task CreateStreamIStreamRequestShouldUseDefaultCancellationTokenWhenNullReturnedFromAccessorAsync() { // Arrange _cancellationTokenAccessorMock.Setup(accessor => accessor.GetToken()) .Returns((CancellationToken?)null); IStreamRequest <object>?savedRequest = null; var responseItem = new object(); var response = new[] { responseItem }.ToAsyncEnumerable(); var savedCancellationToken = default(CancellationToken); _mediatorMock .Setup( m => m.CreateStream( It.IsAny <IStreamRequest <object> >(), It.IsAny <CancellationToken>())) .Returns(response) .Callback <IStreamRequest <object>, CancellationToken>((req, token) => { savedRequest = req; savedCancellationToken = token; }); var request = new Mock <IStreamRequest <object> >().Object; // Act object?result = null; await foreach (var o in _sut.CreateStream(request, _cancellationToken)) { result = o; } // Assert #pragma warning disable IDISP013 // Await in using. using (new AssertionScope()) { #pragma warning disable MA0100 _mediatorMock.Verify( m => m.CreateStream( It.IsAny <IStreamRequest <object> >(), It.IsAny <CancellationToken>())); #pragma warning restore MA0100 savedRequest.Should().Be(request); savedCancellationToken.Should().Be(_cancellationToken); result.Should().Be(responseItem); } #pragma warning restore IDISP013 // Await in using. }
public IAsyncEnumerable <TResponse> CreateStream <TResponse>(IStreamRequest <TResponse> request, CancellationToken cancellationToken = new CancellationToken()) { throw new NotImplementedException(); }
public IAsyncEnumerable <TResponse> CreateStream <TResponse>( IStreamRequest <TResponse> request, CancellationToken cancellationToken = default) { throw new NotSupportedException(); }
/// <summary> /// Initializes a new instance of the <see cref="StreamResponse"/> class. /// </summary> /// <param name="data">The data.</param> /// <param name="next">The next request.</param> public StreamResponse(IEnumerable <Tweet> data, IStreamRequest next) { this.Data = data; this.Next = next; }
public IAsyncEnumerable <TResponse> CreateStream <TResponse>( IStreamRequest <TResponse> request, CancellationToken cancellationToken = default) { return(Array.Empty <TResponse>().ToAsyncEnumerable()); }
public IAsyncEnumerable <TResponse> CreateStream <TResponse>(IStreamRequest <TResponse> request, CancellationToken cancellationToken = default) { return(default(IAsyncEnumerable <TResponse>)); }