-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: or-2389 add locaties for power bi export
- Loading branch information
Showing
5 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/AssociationRegistry.PowerBi.ExportHost/Records/LocatiesRecord.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace AssociationRegistry.PowerBi.ExportHost.Records; | ||
|
||
using CsvHelper.Configuration.Attributes; | ||
|
||
record LocatiesRecord( | ||
[property: Name("adresId.broncode"), Index(0)] string AdresIdBroncode, | ||
[property: Name("adresId.bronwaarde"), Index(1)] string AdresIdBronwaarde, | ||
[property: Name("adresvoorstelling"), Index(2)] string Adresvoorstelling, | ||
[property: Name("bron"), Index(3)] string Bron, | ||
[property: Name("busnummer"), Index(4)] string Busnummer, | ||
[property: Name("gemeente"), Index(5)] string Gemeente, | ||
[property: Name("huisnummer"), Index(6)] string Huisnummer, | ||
[property: Name("isPrimair"), Index(7)] bool IsPrimair, | ||
[property: Name("land"), Index(8)] string Land, | ||
[property: Name("locatieId"), Index(9)] int LocatieId, | ||
[property: Name("locatieType"), Index(10)] string LocatieType, | ||
[property: Name("naam"), Index(11)] string Naam, | ||
[property: Name("postcode"), Index(12)] string PostCode, | ||
[property: Name("straatnaam"), Index(13)] string Straatnaam, | ||
[property: Name("vCode"), Index(14)] string VCode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
test/AssociationRegistry.Test.PowerBi.ExportHost/LocatiesExportTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
namespace AssociationRegistry.Test.PowerBi.ExportHost; | ||
|
||
using Admin.Schema.PowerBiExport; | ||
using AssociationRegistry.PowerBi.ExportHost; | ||
using AutoFixture; | ||
using Common.AutoFixture; | ||
using FluentAssertions; | ||
using System.Text; | ||
using Xunit; | ||
|
||
public class LocatiesExportTests | ||
{ | ||
[Fact] | ||
public async Task WithMultipleDocuments_ThenCsvExportShouldExport() | ||
{ | ||
|
||
var fixture = new Fixture().CustomizeDomain(); | ||
|
||
var docs = fixture.CreateMany<PowerBiExportDocument>(); | ||
|
||
var content = await GenerateCsv(docs); | ||
var stringBuilder = new StringBuilder(); | ||
stringBuilder.Append("adresId.broncode,adresId.bronwaarde,adresvoorstelling,bron,busnummer,gemeente,huisnummer,isPrimair,land,locatieId,locatieType,naam,postcode,straatnaam,vCode\r\n"); | ||
|
||
foreach (var doc in docs) | ||
{ | ||
foreach (var locatie in doc.Locaties) | ||
{ | ||
stringBuilder.Append( | ||
$"{locatie.AdresId?.Broncode},{locatie.AdresId?.Bronwaarde},{locatie.Adresvoorstelling},{locatie.Bron},{locatie.Adres?.Busnummer},{locatie.Adres?.Gemeente},{locatie.Adres?.Huisnummer},{locatie.IsPrimair},{locatie.Adres?.Land},{locatie.LocatieId},{locatie.Locatietype},{locatie.Naam},{locatie.Adres?.Postcode},{locatie.Adres?.Straatnaam},{doc.VCode}\r\n"); | ||
} | ||
} | ||
content.Should().BeEquivalentTo(stringBuilder.ToString()); | ||
} | ||
|
||
private static async Task<string> GenerateCsv(IEnumerable<PowerBiExportDocument> docs) | ||
{ | ||
var exporter = new PowerBiDocumentExporter(); | ||
|
||
var exportStream = await exporter.ExportLocaties(docs); | ||
|
||
using var reader = new StreamReader(exportStream, Encoding.UTF8); | ||
|
||
var content = await reader.ReadToEndAsync(); | ||
|
||
return content; | ||
} | ||
} | ||
|
||
|