diff --git a/src/CouchDB.Driver/Types/ExecutionStats.cs b/src/CouchDB.Driver/Types/ExecutionStats.cs index dbc1e1f..4bd2852 100644 --- a/src/CouchDB.Driver/Types/ExecutionStats.cs +++ b/src/CouchDB.Driver/Types/ExecutionStats.cs @@ -35,6 +35,6 @@ public sealed class ExecutionStats /// Total execution time in milliseconds as measured by the database. /// [JsonProperty("execution_time_ms")] - public int ExecutionTimeMs { get; internal set; } + public float ExecutionTimeMs { get; internal set; } } } diff --git a/tests/CouchDB.Driver.E2ETests/Client_Tests.cs b/tests/CouchDB.Driver.E2ETests/Client_Tests.cs index 33e223e..5e17edd 100644 --- a/tests/CouchDB.Driver.E2ETests/Client_Tests.cs +++ b/tests/CouchDB.Driver.E2ETests/Client_Tests.cs @@ -1,4 +1,4 @@ -using CouchDB.Driver.Types; +using CouchDB.Driver.Types; using System.IO; using System.Linq; using System.Net.Mime; @@ -8,12 +8,13 @@ using CouchDB.Driver.E2ETests.Models; using CouchDB.Driver.Extensions; using CouchDB.Driver.Local; +using CouchDB.Driver.Query.Extensions; using Xunit; namespace CouchDB.Driver.E2E { [Trait("Category", "Integration")] - public class ClientTests: IAsyncLifetime + public class ClientTests : IAsyncLifetime { private ICouchClient _client; private ICouchDatabase _rebels; @@ -22,6 +23,9 @@ public async Task InitializeAsync() { _client = new CouchClient("http://localhost:5984", c => c.UseBasicAuthentication("admin", "admin")); + // ensure the _users database exists to prevent couchdb from + // generating tons of errors in the logs + await _client.GetOrCreateUsersDatabaseAsync(); _rebels = await _client.GetOrCreateDatabaseAsync(); } @@ -152,7 +156,7 @@ public async Task Crud_SpecialCharacters() public async Task Users() { var users = await _client.GetOrCreateUsersDatabaseAsync(); - + CouchUser luke = await users.AddAsync(new CouchUser(name: "luke", password: "lasersword")); Assert.Equal("luke", luke.Name); @@ -266,5 +270,18 @@ public async Task LocalDocuments() var containsId = docs.Select(d => d.Id).Contains("_local/" + docId); Assert.True(containsId); } + + [Fact] + public async Task ExecutionStats() + { + await using var context = new MyDeathStarContext(); + + var rebels = await context.Rebels + .Where(r => r.Age == 19) + .IncludeExecutionStats() + .ToCouchListAsync(); + + Assert.True(rebels.ExecutionStats.ExecutionTimeMs > 0); + } } }