feat(infrastructure): ProductQueryRepository.CountActiveByRubroAsync + integration test
Implementa SELECT COUNT(1) FROM dbo.Product WHERE RubroId = @RubroId AND IsActive = 1. Tests de integración verifican: 0 sin productos, count correcto con mix activos/inactivos/otro rubro, y solo inactivos retorna 0.
This commit is contained in:
@@ -34,4 +34,16 @@ public sealed class ProductQueryRepository : IProductQueryRepository
|
||||
var result = await connection.ExecuteScalarAsync<int>(sql, new { ProductTypeId = productTypeId });
|
||||
return result == 1;
|
||||
}
|
||||
|
||||
public async Task<int> CountActiveByRubroAsync(int rubroId, CancellationToken ct = default)
|
||||
{
|
||||
const string sql = """
|
||||
SELECT COUNT(1) FROM dbo.Product WHERE RubroId = @RubroId AND IsActive = 1
|
||||
""";
|
||||
|
||||
await using var connection = _factory.CreateConnection();
|
||||
await connection.OpenAsync(ct);
|
||||
|
||||
return await connection.ExecuteScalarAsync<int>(sql, new { RubroId = rubroId });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user