Skip to content

Commit d8a60ad

Browse files
authored
Merge pull request #55 from thiagoluga/docs/translate-tests-samples
docs: translate remaining Portuguese identifiers (tests + samples)
2 parents 0e01396 + 79f35e6 commit d8a60ad

27 files changed

Lines changed: 198 additions & 191 deletions

File tree

.github/workflows/sonar.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
/d:sonar.token="${SONAR_TOKEN}" \
6363
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml \
6464
/d:sonar.coverage.exclusions="benchmarks/**,samples/**" \
65+
/d:sonar.cpd.exclusions="benchmarks/**,samples/**" \
6566
/d:sonar.qualitygate.wait=true
6667
dotnet build NeoReports.sln --configuration Release
6768
dotnet-coverage collect "dotnet test NeoReports.sln --configuration Release --no-build" -f xml -o coverage.xml

samples/01-sql-to-csv-local/Program.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
using NeoReports.Core.Pipeline;
66
using NeoReports.Destinations.Local;
77
using NeoReports.Formats.Csv;
8+
using NeoReports.Samples.SqlToCsvLocal;
89
using NeoReports.Sources.Sql;
910
using static NeoReports.Core.Building.ReportColumns;
1011

1112
// Sample 01 — SQL Server -> CSV -> local filesystem (the first end-to-end report).
1213
//
13-
// Run against any SQL Server with a Vendas table:
14+
// Run against any SQL Server with a Sales table:
1415
// dotnet run --project samples/01-sql-to-csv-local -- "<connection-string>"
1516
//
16-
// Expected schema: Vendas(Id BIGINT, Cliente NVARCHAR, Valor DECIMAL, Data DATETIME2).
17+
// Expected schema: Sales(Id BIGINT, Customer NVARCHAR, Amount DECIMAL, Date DATETIME2).
1718

1819
var connectionString = args.Length > 0
1920
? args[0]
@@ -22,31 +23,29 @@
2223
var services = new ServiceCollection();
2324
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Information));
2425

25-
services.AddReport<Venda>("vendas-mensal", b => b
26+
services.AddReport<Sale>("monthly-sales", b => b
2627
.From(Source.Sql(
2728
connectionString,
28-
"SELECT Id, Cliente, Valor, Data FROM Vendas " +
29+
"SELECT Id, Customer, Amount, Date FROM Sales " +
2930
"WHERE (@cursor IS NULL OR Id > @cursor) ORDER BY Id")
30-
.Keyset<Venda, long>(v => v.Id, pageSize: 1000))
31-
.Filter(v => v.Valor > 0)
31+
.Keyset<Sale, long>(v => v.Id, pageSize: 1000))
32+
.Filter(v => v.Amount > 0)
3233
.Columns(
33-
Col<Venda, long>(v => v.Id, "ID Venda"),
34-
Col<Venda, string>(v => v.Cliente, "Cliente"),
35-
Col<Venda, decimal>(v => v.Valor, "Valor", format: "C2", culture: "pt-BR"),
36-
Col<Venda, DateTime>(v => v.Data, "Data Venda", format: "yyyy-MM-dd"))
34+
Col<Sale, long>(v => v.Id, "Sale ID"),
35+
Col<Sale, string>(v => v.Customer, "Customer"),
36+
Col<Sale, decimal>(v => v.Amount, "Amount", format: "C2", culture: "pt-BR"),
37+
Col<Sale, DateTime>(v => v.Date, "Sale Date", format: "yyyy-MM-dd"))
3738
.To(Format.Csv(o => o.Delimiter(';').Encoding(Encoding.UTF8)))
3839
.UploadTo(Destination.Local("./out/{name}-{date:yyyy-MM-dd}.{ext}")));
3940

4041
var provider = services.BuildServiceProvider();
4142
var runner = provider.GetRequiredService<IReportRunner>();
4243

43-
var result = await runner.RunAsync("vendas-mensal");
44+
var result = await runner.RunAsync("monthly-sales");
4445

4546
Console.WriteLine($"Status: {result.Status}");
4647
Console.WriteLine($"Records read/written: {result.Stats.RecordsRead}/{result.Stats.RecordsWritten}");
4748
foreach (var upload in result.Uploads)
4849
Console.WriteLine($"Uploaded: {upload.RemotePath} (success={upload.Success})");
4950

5051
return result.Status == ReportRunStatus.Failed ? 1 : 0;
51-
52-
internal sealed record Venda(long Id, string Cliente, decimal Valor, DateTime Data);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace NeoReports.Samples.SqlToCsvLocal;
2+
3+
/// <summary>The report row type for the sample, in a named namespace (not a top-level type).</summary>
4+
public sealed record Sale(long Id, string Customer, decimal Amount, DateTime Date);

samples/02-sql-to-xlsx-s3/Program.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using NeoReports.Core.DependencyInjection;
55
using NeoReports.Core.Pipeline;
66
using NeoReports.Destinations.S3;
7+
using NeoReports.Samples.SqlToXlsxS3;
78
using NeoReports.Sources.Sql;
89
using static NeoReports.Core.Building.ReportColumns;
910
// Import the format entry methods directly so Csv(...) and Xlsx(...) read cleanly and avoid the
@@ -25,32 +26,30 @@
2526
var services = new ServiceCollection();
2627
services.AddLogging(b => b.AddConsole().SetMinimumLevel(LogLevel.Information));
2728

28-
services.AddReport<Venda>("vendas-mensal", b => b
29+
services.AddReport<Sale>("monthly-sales", b => b
2930
.From(Source.Sql(
3031
connectionString,
31-
"SELECT Id, Cliente, Valor, Data FROM Vendas " +
32+
"SELECT Id, Customer, Amount, Date FROM Sales " +
3233
"WHERE (@cursor IS NULL OR Id > @cursor) ORDER BY Id")
33-
.Keyset<Venda, long>(v => v.Id, pageSize: 1000))
34-
.Filter(v => v.Valor > 0)
34+
.Keyset<Sale, long>(v => v.Id, pageSize: 1000))
35+
.Filter(v => v.Amount > 0)
3536
.Columns(
36-
Col<Venda, long>(v => v.Id, "ID Venda"),
37-
Col<Venda, string>(v => v.Cliente, "Cliente"),
38-
Col<Venda, decimal>(v => v.Valor, "Valor", format: "C2", culture: "pt-BR"),
39-
Col<Venda, DateTime>(v => v.Data, "Data Venda", format: "yyyy-MM-dd"))
37+
Col<Sale, long>(v => v.Id, "Sale ID"),
38+
Col<Sale, string>(v => v.Customer, "Customer"),
39+
Col<Sale, decimal>(v => v.Amount, "Amount", format: "C2", culture: "pt-BR"),
40+
Col<Sale, DateTime>(v => v.Date, "Sale Date", format: "yyyy-MM-dd"))
4041
.To(Csv(o => o.Delimiter(';').Encoding(Encoding.UTF8)))
41-
.To(Xlsx(o => o.SheetName("Vendas").AutoFilter()))
42+
.To(Xlsx(o => o.SheetName("Sales").AutoFilter()))
4243
.UploadTo(Destination.S3(bucket, "reports/{name}/{date:yyyy-MM-dd}.{ext}")));
4344

4445
var provider = services.BuildServiceProvider();
4546
var runner = provider.GetRequiredService<IReportRunner>();
4647

47-
var result = await runner.RunAsync("vendas-mensal");
48+
var result = await runner.RunAsync("monthly-sales");
4849

4950
Console.WriteLine($"Status: {result.Status}");
5051
Console.WriteLine($"Records read/written: {result.Stats.RecordsRead}/{result.Stats.RecordsWritten}");
5152
foreach (var upload in result.Uploads)
5253
Console.WriteLine($"Uploaded: {upload.Url} (success={upload.Success})");
5354

5455
return result.Status == ReportRunStatus.Failed ? 1 : 0;
55-
56-
internal sealed record Venda(long Id, string Cliente, decimal Valor, DateTime Data);

samples/02-sql-to-xlsx-s3/Sale.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
namespace NeoReports.Samples.SqlToXlsxS3;
2+
3+
/// <summary>The report row type for the sample, in a named namespace (not a top-level type).</summary>
4+
public sealed record Sale(long Id, string Customer, decimal Amount, DateTime Date);

src/Formats/NeoReports.Formats.Xlsx/XlsxOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace NeoReports.Formats.Xlsx;
22

33
/// <summary>
4-
/// Fluent options for the XLSX writer (<c>o.SheetName("Vendas").AutoFilter()</c>).
4+
/// Fluent options for the XLSX writer (<c>o.SheetName("Sales").AutoFilter()</c>).
55
/// Defaults: sheet "Sheet1", a header row from each column's <c>DisplayName</c>, auto-filter off.
66
/// </summary>
77
public sealed class XlsxOptions

tests/NeoReports.AspNetCore.IntegrationTests/EndpointsTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public async Task List_reports_returns_registered_report()
2929
var reports = await client.GetFromJsonAsync<List<JsonElement>>("/api/reports", Json);
3030

3131
reports.ShouldNotBeNull();
32-
reports.ShouldContain(r => r.GetProperty("name").GetString() == "vendas");
32+
reports.ShouldContain(r => r.GetProperty("name").GetString() == "sales");
3333
}
3434

3535
[Fact]
@@ -39,7 +39,7 @@ public async Task Async_run_goes_queued_to_completed_and_downloads()
3939
var client = host.GetTestClient();
4040

4141
// CA-9: async trigger returns 202 + jobId.
42-
var run = await client.PostAsJsonAsync("/api/reports/vendas/run", new { parameters = (object?)null }, Json);
42+
var run = await client.PostAsJsonAsync("/api/reports/sales/run", new { parameters = (object?)null }, Json);
4343
run.StatusCode.ShouldBe(HttpStatusCode.Accepted);
4444

4545
var accepted = await run.Content.ReadFromJsonAsync<JsonElement>(Json);
@@ -65,7 +65,7 @@ public async Task Async_run_goes_queued_to_completed_and_downloads()
6565
download.Content.Headers.ContentDisposition!.FileName!.Trim('"').ShouldEndWith(".csv");
6666

6767
var text = await download.Content.ReadAsStringAsync();
68-
text.ShouldContain("ID;Cliente"); // header
68+
text.ShouldContain("ID;Customer"); // header
6969
text.ShouldContain("1;C1"); // first row
7070
var dataLines = text.Split('\n', StringSplitOptions.RemoveEmptyEntries);
7171
dataLines.Length.ShouldBe(31); // header + 30 rows
@@ -78,14 +78,14 @@ public async Task Sync_run_streams_single_output_with_content_disposition()
7878
var client = host.GetTestClient();
7979

8080
// CA-10: sync streams the file directly.
81-
var response = await client.PostAsJsonAsync("/api/reports/vendas/run?mode=sync", new { }, Json);
81+
var response = await client.PostAsJsonAsync("/api/reports/sales/run?mode=sync", new { }, Json);
8282

8383
response.StatusCode.ShouldBe(HttpStatusCode.OK);
8484
response.Content.Headers.ContentType!.MediaType.ShouldBe("text/csv");
8585
response.Content.Headers.ContentDisposition!.FileName!.Trim('"').ShouldEndWith(".csv");
8686

8787
var text = await response.Content.ReadAsStringAsync();
88-
text.ShouldContain("ID;Cliente");
88+
text.ShouldContain("ID;Customer");
8989
text.ShouldContain("30;C30");
9090
}
9191

@@ -94,7 +94,7 @@ public async Task Sync_run_rejects_multi_output_with_400()
9494
{
9595
using var host = await TestApp.StartAsync(services =>
9696
{
97-
services.AddReport<Venda>("multi", b => b
97+
services.AddReport<Sale>("multi", b => b
9898
.From(new InMemorySource(rows: 5, pageSize: 10))
9999
.Column(v => v.Id, "ID")
100100
.To(Csv(o => o.Delimiter(';')))
@@ -157,7 +157,7 @@ public async Task Cancel_running_job_is_accepted()
157157
// A slow source keeps the job running long enough to cancel it deterministically.
158158
using var host = await TestApp.StartAsync(services =>
159159
{
160-
services.AddReport<Venda>("slow", b => b
160+
services.AddReport<Sale>("slow", b => b
161161
.From(new InMemorySource(rows: 100_000, pageSize: 10, delay: TimeSpan.FromMilliseconds(20)))
162162
.Column(v => v.Id, "ID")
163163
.To(Csv(o => o.Delimiter(';'))));
@@ -185,7 +185,7 @@ public async Task Download_multi_output_returns_zip()
185185
{
186186
using var host = await TestApp.StartAsync(services =>
187187
{
188-
services.AddReport<Venda>("multi", b => b
188+
services.AddReport<Sale>("multi", b => b
189189
.From(new InMemorySource(rows: 5, pageSize: 10))
190190
.Column(v => v.Id, "ID")
191191
.To(Csv(o => o.Delimiter(';')))

tests/NeoReports.AspNetCore.IntegrationTests/TestApp.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
namespace NeoReports.AspNetCore.IntegrationTests;
1717

1818
/// <summary>Reference row type for the API tests.</summary>
19-
public sealed record Venda(long Id, string Cliente);
19+
public sealed record Sale(long Id, string Customer);
2020

2121
/// <summary>In-memory batch source synthesizing a fixed number of rows, one page at a time.</summary>
22-
public sealed class InMemorySource : IBatchSource<Venda>
22+
public sealed class InMemorySource : IBatchSource<Sale>
2323
{
2424
private readonly long _rows;
2525
private readonly int _pageSize;
@@ -34,23 +34,23 @@ public InMemorySource(long rows, int pageSize, TimeSpan delay = default)
3434

3535
public ReportSchema Schema { get; } = new(new[] { new ReportColumn("Id", ColumnType.Integer) });
3636

37-
public async Task<BatchResult<Venda>> ReadBatchAsync(BatchContext context, CancellationToken cancellationToken)
37+
public async Task<BatchResult<Sale>> ReadBatchAsync(BatchContext context, CancellationToken cancellationToken)
3838
{
3939
if (_delay > TimeSpan.Zero)
4040
await Task.Delay(_delay, cancellationToken).ConfigureAwait(false);
4141

4242
var last = context.Cursor is null ? 0L : long.Parse(context.Cursor, System.Globalization.CultureInfo.InvariantCulture);
4343
var start = last + 1;
4444
if (start > _rows)
45-
return BatchResult<Venda>.Empty;
45+
return BatchResult<Sale>.Empty;
4646

4747
var end = Math.Min(start + _pageSize - 1, _rows);
48-
var rows = new List<Venda>();
48+
var rows = new List<Sale>();
4949
for (var id = start; id <= end; id++)
50-
rows.Add(new Venda(id, $"C{id}"));
50+
rows.Add(new Sale(id, $"C{id}"));
5151

5252
var hasMore = end < _rows;
53-
return new BatchResult<Venda>(rows, hasMore ? end.ToString(System.Globalization.CultureInfo.InvariantCulture) : null, hasMore);
53+
return new BatchResult<Sale>(rows, hasMore ? end.ToString(System.Globalization.CultureInfo.InvariantCulture) : null, hasMore);
5454
}
5555
}
5656

@@ -76,10 +76,10 @@ public static async Task<IHost> StartAsync(Action<IServiceCollection>? configure
7676
}
7777
else
7878
{
79-
services.AddReport<Venda>("vendas", b => b
79+
services.AddReport<Sale>("sales", b => b
8080
.From(new InMemorySource(rows: 30, pageSize: 10))
8181
.Column(v => v.Id, "ID")
82-
.Column(v => v.Cliente, "Cliente")
82+
.Column(v => v.Customer, "Customer")
8383
.To(Csv(o => o.Delimiter(';'))));
8484
}
8585

tests/NeoReports.Core.UnitTests/Fakes/TestFakes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace NeoReports.Core.UnitTests.Fakes;
55

66
/// <summary>Reference row type used across the tests.</summary>
7-
public sealed record Venda(long Id, string Cliente, decimal Valor, DateTime Data);
7+
public sealed record Sale(long Id, string Customer, decimal Amount, DateTime Date);
88

99
/// <summary>Minimal service provider that resolves nothing (factories under test ignore it).</summary>
1010
public sealed class EmptyServiceProvider : IServiceProvider

tests/NeoReports.Core.UnitTests/FileSystemArtifactStoreTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public async Task Save_then_list_round_trips_file_and_mime()
2323
var store = new FileSystemArtifactStore(_root);
2424
var src = MakeSourceFile("id;name\n1;Ana\n");
2525

26-
await store.SaveAsync("job-1", src, "vendas.csv", "text/csv", Ct);
26+
await store.SaveAsync("job-1", src, "sales.csv", "text/csv", Ct);
2727

2828
var artifacts = await store.ListAsync("job-1", Ct);
2929
var artifact = artifacts.ShouldHaveSingleItem();
30-
artifact.FileName.ShouldBe("vendas.csv");
30+
artifact.FileName.ShouldBe("sales.csv");
3131
artifact.MimeType.ShouldBe("text/csv");
3232
artifact.SizeBytes.ShouldBeGreaterThan(0);
3333
File.Exists(artifact.Path).ShouldBeTrue();

0 commit comments

Comments
 (0)