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_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 InitializeAsync_Success_PreResultFieldsPresent() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Analytics\good-request.json"); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); // Act await queryResult.InitializeAsync(); // Assert Assert.Equal("30f6bcdf-2288-4fe1-bea1-361bb96984a4", queryResult.MetaData.RequestId); Assert.NotNull(queryResult.MetaData.Signature); }
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_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); }
public async Task InitializeAsync_Error_AllResultFieldsPresent() { // Arrange using var stream = ResourceHelper.ReadResourceAsStream(@"Documents\Analytics\syntax-24000.json"); using var queryResult = new BlockAnalyticsResult <dynamic>(stream, new DefaultSerializer()); // Act await queryResult.InitializeAsync(); // Assert Assert.Equal("eb8a8d08-9e25-4473-81f8-6565c51a43d9", queryResult.MetaData.RequestId); Assert.NotEmpty(queryResult.Errors); Assert.Equal(AnalyticsStatus.Fatal, queryResult.MetaData.Status); Assert.NotNull(queryResult.MetaData.Metrics); Assert.Equal("161.673835ms", queryResult.MetaData.Metrics.ElaspedTime); }