public async Task GetAsyncEnumerator_CalledTwice_StreamAlreadyReadException(string filename) { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(filename); using var viewResult = new BlockViewResult <dynamic, dynamic>(HttpStatusCode.OK, "OK", stream, new DefaultSerializer()); await viewResult.InitializeAsync().ConfigureAwait(false); // Act/Assert await viewResult.ToListAsync().ConfigureAwait(false); await Assert.ThrowsAsync <StreamAlreadyReadException>(() => viewResult.ToListAsync().AsTask()).ConfigureAwait(false); }
public async Task GetAsyncEnumerator_HasNotInitialized_InvalidOperationException() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Views\200-success.json"); using var viewResult = new BlockViewResult <dynamic, dynamic>(HttpStatusCode.OK, "OK", stream, new DefaultSerializer()); // Act/Assert await Assert.ThrowsAsync <InvalidOperationException>(() => viewResult.ToListAsync().AsTask()).ConfigureAwait(false); }
public async Task GetAsyncEnumerator_NoStream_Empty() { // Arrange using var viewResult = new BlockViewResult <dynamic, dynamic>(HttpStatusCode.OK, "OK", new DefaultSerializer()); // Act await viewResult.InitializeAsync().ConfigureAwait(false); var result = await viewResult.ToListAsync().ConfigureAwait(false); // Assert Assert.Empty(result); }
public async Task GetAsyncEnumerator_HasInitialized_GetsResults() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Views\200-success.json"); using var viewResult = new BlockViewResult <dynamic, dynamic>(HttpStatusCode.OK, "OK", stream, new DefaultSerializer()); await viewResult.InitializeAsync().ConfigureAwait(false); // Act var result = await viewResult.ToListAsync().ConfigureAwait(false); // Assert Assert.NotEmpty(result); }
public async Task GetAsyncEnumerator_AfterEnumeration_PreResultFieldsStillPresent() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Views\200-success.json"); using var viewResult = new BlockViewResult <dynamic, dynamic>(HttpStatusCode.OK, "OK", stream, new DefaultSerializer()); await viewResult.InitializeAsync().ConfigureAwait(false); // Act await viewResult.ToListAsync().ConfigureAwait(false); // Assert Assert.Equal(4u, viewResult.MetaData.TotalRows); }