public async Task GetAsyncEnumerator_CalledTwice_StreamAlreadyReadException(string filename) { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(filename); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); await queryResult.InitializeAsync(); // Act/Assert await queryResult.ToListAsync(); await Assert.ThrowsAsync <StreamAlreadyReadException>(() => queryResult.ToListAsync().AsTask()); }
public async Task GetAsyncEnumerator_HasNotInitialized_InvalidOperationException() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Analytics\good-request.json"); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); // Act/Assert await Assert.ThrowsAsync <InvalidOperationException>(() => queryResult.ToListAsync().AsTask()); }
public async Task GetAsyncEnumerator_NoResults_Empty() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Query\query-n1ql-error-response-400.json"); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); await queryResult.InitializeAsync(); // Act var result = await queryResult.ToListAsync(); // Assert Assert.Empty(result); }
public async Task GetAsyncEnumerator_HasInitialized_GetsResults() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Analytics\good-request.json"); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); await queryResult.InitializeAsync(); // Act var result = await queryResult.ToListAsync(); // Assert Assert.Equal(AnalyticsStatus.Success, queryResult.MetaData.Status); Assert.NotEmpty(result); }
public async Task GetAsyncEnumerator_AfterEnumeration_PreResultFieldsStillPresent() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Analytics\good-request.json"); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); await queryResult.InitializeAsync(); // Act await queryResult.ToListAsync(); // Assert Assert.Equal("30f6bcdf-2288-4fe1-bea1-361bb96984a4", queryResult.MetaData.RequestId); Assert.NotNull(queryResult.MetaData.Signature); }
public async Task GetAsyncEnumerator_AfterEnumeration_HasErrors(string filename, AnalyticsStatus expectedStatus) { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(filename); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); await queryResult.InitializeAsync(); // Act await queryResult.ToListAsync(); var result = queryResult.MetaData.Status; // Assert Assert.Equal(expectedStatus, result); Assert.NotEmpty(queryResult.Errors); }