Skip to content

Commit 4a42dc6

Browse files
committed
PoemMetadataChecker always throws exceptions now
1 parent d303314 commit 4a42dc6

11 files changed

Lines changed: 144 additions & 159 deletions

src/Tests/Consistency/YamlMetadataCheckerTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ public class YamlMetadataCheckerTest(WithRealDataFixture fixture, ITestOutputHel
99
{
1010
[Fact]
1111
[Trait("UnitTest", "MetadataCheck")]
12-
public async Task ShouldNotFindMissingYearTagInYamlMetadata()
12+
public void ShouldNotFindMissingYearTagInYamlMetadata()
1313
{
14-
var anomalies = await new YamlMetadataChecker(fixture.Configuration, fixture.Data).GetYamlMetadataAnomaliesAcrossSeasonsAsync().ToListAsync();
14+
var anomalies = new YamlMetadataChecker(fixture.Configuration, fixture.Data).GetYamlMetadataAnomaliesAcrossSeasons();
1515
testOutputHelper.WriteLine(string.Join(Environment.NewLine, anomalies));
1616
anomalies.ShouldBeEmpty();
1717
}

src/Tests/Importers/PoemImporterTest.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class PoemImporterTest(BasicFixture fixture): IClassFixture<BasicFixture>
1717
public void ShouldNotImportPoemWithIdNotEndingWithSeasonId(string poemId, Root data)
1818
{
1919
var poemContentImporter = new PoemImporter(fixture.Configuration);
20-
var act = () => poemContentImporter.ImportPoemAsync(poemId, data);
20+
var act = () => poemContentImporter.ImportPoem(poemId, data);
2121
var ex = act.ShouldThrow<ArgumentException>();
2222
ex.Message.ShouldBe($"'{poemId}' does not end with season id");
2323
}
@@ -28,7 +28,7 @@ public void ShouldNotImportPoemWithIdNotEndingWithSeasonId(string poemId, Root d
2828
public void ShouldNotImportPoemWhoseSeasonDirectoryDoesNotExist(Root data)
2929
{
3030
var poemContentImporter = new PoemImporter(fixture.Configuration);
31-
var act = () => poemContentImporter.ImportPoemAsync("some_poem_99", data);
31+
var act = () => poemContentImporter.ImportPoem("some_poem_99", data);
3232
var ex = act.ShouldThrow<ArgumentException>();
3333
ex.Message.ShouldBe($"No such season content directory for id '99'. Create season directory before importing poem");
3434
}
@@ -39,25 +39,25 @@ public void ShouldNotImportPoemWhoseSeasonDirectoryDoesNotExist(Root data)
3939
public void ShouldNotImportPoemWhoseContentFileDoesNotExist(Root data)
4040
{
4141
var poemContentImporter = new PoemImporter(fixture.Configuration);
42-
var act = () => poemContentImporter.ImportPoemAsync("some_poem_16", data);
42+
var act = () => poemContentImporter.ImportPoem("some_poem_16", data);
4343
var ex = act.ShouldThrow<ArgumentException>();
4444
ex.Message.ShouldStartWith($"Poem content file not found: ");
4545
}
4646

4747
[Theory]
4848
[Trait("UnitTest", "ContentImport")]
4949
[AutoDomainData]
50-
public async Task ShouldImportPoemsOfSeason(Root data)
50+
public void ShouldImportPoemsOfSeason(Root data)
5151
{
5252
var poemContentImporter = new PoemImporter(fixture.Configuration);
53-
await poemContentImporter.ImportPoemsOfSeasonAsync(16, data);
53+
poemContentImporter.ImportPoemsOfSeason(16, data);
5454
data.Seasons.FirstOrDefault(x => x.Id == 16).ShouldNotBeNull();
5555
data.Seasons.FirstOrDefault(x => x.Id == 16).Poems.ShouldNotBeEmpty();
5656
}
5757

5858
[Fact]
5959
[Trait("UnitTest", "ContentImport")]
60-
public async Task ShouldImportVariableVerseLength()
60+
public void ShouldImportVariableVerseLength()
6161
{
6262
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
6363
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "3_troisieme_saison/jeux_de_nuits.md");
@@ -67,13 +67,12 @@ public async Task ShouldImportVariableVerseLength()
6767
poem.DetailedMetric.ShouldBe("8, 6, 4, 2");
6868
// Because it has been copied from DetailedVerseLength by poemContentImporter.
6969
poem.VerseLength.ShouldBe("8, 6, 4, 2");
70-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
71-
anomalies.ShouldBeEmpty();
70+
poemContentImporter.VerifyAnomaliesAfterImport();
7271
}
7372

7473
[Fact]
7574
[Trait("UnitTest", "ContentImport")]
76-
public async Task ShouldImportVariableVerseLengthWhenMoreTextAfterVerseLength()
75+
public void ShouldImportVariableVerseLengthWhenMoreTextAfterVerseLength()
7776
{
7877
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
7978
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "19_dix_neuvieme_saison/urgence.md");
@@ -85,8 +84,7 @@ public async Task ShouldImportVariableVerseLengthWhenMoreTextAfterVerseLength()
8584
poem.DetailedMetric.ShouldBe("5, 2");
8685
// Because it has been copied from DetailedVerseLength by poemContentImporter.
8786
poem.VerseLength.ShouldBe("5, 2");
88-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
89-
anomalies.ShouldBeEmpty();
87+
poemContentImporter.VerifyAnomaliesAfterImport();
9088
}
9189

9290
[Fact]

src/Tests/Processors/PoemContentProcessorTest.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ public class PoemContentProcessorTest(BasicFixture fixture) : IClassFixture<Basi
1111
[Trait("UnitTest", "ContentImport")]
1212
[InlineData("16_seizieme_saison/oiseaux_de_juillet.md", 3, 4)]
1313
[InlineData("16_seizieme_saison/sur_les_toits_la_pluie.md", 1, 18)]
14-
public async Task ShouldImportParagraphs(string poemContentPath, int paragraphs, int verses)
14+
public void ShouldImportParagraphs(string poemContentPath, int paragraphs, int verses)
1515
{
1616
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
1717
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, poemContentPath);
1818
var poemContentImporter = new PoemImporter(fixture.Configuration);
1919
var (poem, _) = poemContentImporter.Import(poemContentFilePath);
2020
poem.Paragraphs.Count.ShouldBe(paragraphs);
2121
poem.Paragraphs.ForEach(p => p.Verses.Count.ShouldBe(verses));
22-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
23-
anomalies.ShouldBeEmpty();
22+
poemContentImporter.VerifyAnomaliesAfterImport();
2423
}
2524
}

src/Tests/Processors/PoemTomlMetadataProcessorTest.cs

Lines changed: 30 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class PoemTomlMetadataProcessorTest(BasicFixture fixture) : IClassFixture
1010
{
1111
[Fact]
1212
[Trait("UnitTest", "ContentImport")]
13-
private async Task ShouldImportTomlMetadata()
13+
public void ShouldImportTomlMetadata()
1414
{
1515
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
1616
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!,
@@ -30,13 +30,12 @@ private async Task ShouldImportTomlMetadata()
3030
poem.VerseLength.ShouldBe("12");
3131
poem.Info.ShouldBeNull();
3232
position.ShouldBe(0);
33-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
34-
anomalies.ShouldBeEmpty();
33+
poemContentImporter.VerifyAnomaliesAfterImport();
3534
}
3635

3736
[Fact]
3837
[Trait("UnitTest", "ContentImport")]
39-
private async Task ShouldImportSingleLineInfoTomlMetadata()
38+
public void ShouldImportSingleLineInfoTomlMetadata()
4039
{
4140
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
4241
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "12_douzieme_saison/barcarolle.md");
@@ -48,13 +47,12 @@ private async Task ShouldImportSingleLineInfoTomlMetadata()
4847
poem.Categories.First().SubCategories.Count.ShouldBe(1);
4948
poem.Categories.First().SubCategories.First().ShouldBe("Musique et chant");
5049
poem.Info.ShouldBe("Inspiré par l'air homonyme d'Offenbach.");
51-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
52-
anomalies.ShouldBeEmpty();
50+
poemContentImporter.VerifyAnomaliesAfterImport();
5351
}
5452

5553
[Fact]
5654
[Trait("UnitTest", "ContentImport")]
57-
private async Task ShouldImportMultiLineInfoTomlMetadata()
55+
public void ShouldImportMultiLineInfoTomlMetadata()
5856
{
5957
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
6058
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "11_onzieme_saison/rester.md");
@@ -71,13 +69,12 @@ private async Task ShouldImportMultiLineInfoTomlMetadata()
7169
poem.Info.ShouldEndWith("hidefirstheading %}}");
7270
poem.Info.ShouldBe(
7371
$"\"Tu es beau\" en italien.{Environment.NewLine}{Environment.NewLine}{{{{% include \"../../includes/trop_de_choses_auront_change\" hidefirstheading %}}}}");
74-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
75-
anomalies.ShouldBeEmpty();
72+
poemContentImporter.VerifyAnomaliesAfterImport();
7673
}
7774

7875
[Fact]
7976
[Trait("UnitTest", "ContentImport")]
80-
private async Task ShouldImportDoubleAcrosticheTomlMetadata()
77+
public void ShouldImportDoubleAcrosticheTomlMetadata()
8178
{
8279
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
8380
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "10_dixieme_saison/cathedrale_de_lumieres.md");
@@ -87,13 +84,12 @@ private async Task ShouldImportDoubleAcrosticheTomlMetadata()
8784
poemContentImporter.HasYamlMetadata.ShouldBeFalse();
8885
poem.DoubleAcrostiche!.First.ShouldBe("Cathédrale");
8986
poem.DoubleAcrostiche.Second.ShouldBe("de lumières");
90-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
91-
anomalies.ShouldBeEmpty();
87+
poemContentImporter.VerifyAnomaliesAfterImport();
9288
}
9389

9490
[Fact]
9591
[Trait("UnitTest", "ContentImport")]
96-
private async Task ShouldImportMultipleCategoriesTomlMetadata()
92+
public void ShouldImportMultipleCategoriesTomlMetadata()
9793
{
9894
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
9995
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "15_quinzieme_saison/du_gris_au_noir.md");
@@ -108,13 +104,12 @@ private async Task ShouldImportMultipleCategoriesTomlMetadata()
108104
poem.Categories.FirstOrDefault(x => x.Name == "Saisons").SubCategories.FirstOrDefault().ShouldBe("Automne");
109105
poem.Categories.FirstOrDefault(x => x.Name == "Ombres et lumières").SubCategories.ShouldContain("Ville");
110106
poem.Categories.FirstOrDefault(x => x.Name == "Ombres et lumières").SubCategories.ShouldContain("Crépuscule");
111-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
112-
anomalies.ShouldBeEmpty();
107+
poemContentImporter.VerifyAnomaliesAfterImport();
113108
}
114-
109+
115110
[Fact]
116111
[Trait("UnitTest", "ContentImport")]
117-
private async Task ShouldImportLovecatExtraTag()
112+
public void ShouldImportLovecatExtraTag()
118113
{
119114
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
120115
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "16_seizieme_saison/un_chat_voisin.md");
@@ -123,13 +118,12 @@ private async Task ShouldImportLovecatExtraTag()
123118
poemContentImporter.HasTomlMetadata.ShouldBeTrue();
124119
poemContentImporter.HasYamlMetadata.ShouldBeFalse();
125120
poem.ExtraTags.ShouldBe(["lovecat"]);
126-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
127-
anomalies.ShouldBeEmpty();
121+
poemContentImporter.VerifyAnomaliesAfterImport();
128122
}
129-
123+
130124
[Fact]
131125
[Trait("UnitTest", "ContentImport")]
132-
private async Task ShouldImportLocations()
126+
public void ShouldImportLocations()
133127
{
134128
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
135129
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "12_douzieme_saison/pelerinage.md");
@@ -138,15 +132,14 @@ private async Task ShouldImportLocations()
138132
poemContentImporter.HasTomlMetadata.ShouldBeTrue();
139133
poemContentImporter.HasYamlMetadata.ShouldBeFalse();
140134
poem.Locations.ShouldBe(["Reims"]);
141-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
142-
anomalies.ShouldBeEmpty();
135+
poemContentImporter.VerifyAnomaliesAfterImport();
143136
}
144137

145138
[Theory]
146139
[Trait("UnitTest", "Computation")]
147140
[InlineData("categories = [\"First\", \"Here and there\"]")]
148141
[InlineData("categories = [ \"First\", \"Here and there\" ]")]
149-
private void ShouldProperlyParseCategories(string categoriesLine)
142+
public void ShouldProperlyParseCategories(string categoriesLine)
150143
{
151144
var processor = new PoemTomlMetadataProcessor();
152145
processor.BuildCategories(categoriesLine);
@@ -155,7 +148,7 @@ private void ShouldProperlyParseCategories(string categoriesLine)
155148

156149
[Fact]
157150
[Trait("UnitTest", "Computation")]
158-
private void ShouldProperlyParseInfoWithQuotes()
151+
public void ShouldProperlyParseInfoWithQuotes()
159152
{
160153
var info = "info = \"It is a \\\"quoted text\\\"\"";
161154
var processor = new PoemTomlMetadataProcessor();
@@ -165,7 +158,7 @@ private void ShouldProperlyParseInfoWithQuotes()
165158

166159
[Fact]
167160
[Trait("UnitTest", "ContentImport")]
168-
private async Task ShouldImportPictures()
161+
public void ShouldImportPictures()
169162
{
170163
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
171164
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "17_dix_septieme_saison/une_derniere_visite.md");
@@ -176,13 +169,12 @@ private async Task ShouldImportPictures()
176169
poem.Pictures.ShouldNotBeNull();
177170
poem.Pictures.Count.ShouldBe(4);
178171
poem.Pictures[0].ShouldBe("Le puits du château de Ham-sous-Varsberg");
179-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
180-
anomalies.ShouldBeEmpty();
172+
poemContentImporter.VerifyAnomaliesAfterImport();
181173
}
182174

183175
[Fact]
184176
[Trait("UnitTest", "ContentImport")]
185-
private async Task ShouldImportVariableVerseTomlMetadata()
177+
public void ShouldImportVariableVerseTomlMetadata()
186178
{
187179
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
188180
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "17_dix_septieme_saison/a_quai.md");
@@ -194,28 +186,26 @@ private async Task ShouldImportVariableVerseTomlMetadata()
194186
poem.DetailedMetric.ShouldBe("5, 2");
195187
// Because it has been copied from DetailedVerseLength by poemContentImporter.
196188
poem.VerseLength.ShouldBe("5, 2");
197-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
198-
anomalies.ShouldBeEmpty();
189+
poemContentImporter.VerifyAnomaliesAfterImport();
199190
}
200-
191+
201192
[Fact]
202193
[Trait("UnitTest", "ContentImport")]
203-
private async Task ShouldImportMultilineTags()
194+
public void ShouldImportMultilineTags()
204195
{
205196
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
206197
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "21_vingt_et_unieme_saison/le_jour_decroit.md");
207198
var poemContentImporter = new PoemImporter(fixture.Configuration);
208199
var (poem, _) = poemContentImporter.Import(poemContentFilePath);
209200
poemContentImporter.HasTomlMetadata.ShouldBeTrue();
210201
poemContentImporter.HasYamlMetadata.ShouldBeFalse();
211-
poem.ExtraTags.ShouldBeEquivalentTo(new List<string>{"refrain", "les mois"});
212-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
213-
anomalies.ShouldBeEmpty();
202+
poem.ExtraTags.ShouldBeEquivalentTo(new List<string> { "refrain", "les mois" });
203+
poemContentImporter.VerifyAnomaliesAfterImport();
214204
}
215-
205+
216206
[Fact]
217207
[Trait("UnitTest", "ContentImport")]
218-
private async Task ShouldImportDescription()
208+
public void ShouldImportDescription()
219209
{
220210
var poemContentFilePath = Path.Combine(Directory.GetCurrentDirectory(),
221211
fixture.Configuration[Constants.CONTENT_ROOT_DIR]!, "3_troisieme_saison/est_ce_un_automne.md");
@@ -224,8 +214,6 @@ private async Task ShouldImportDescription()
224214
poemContentImporter.HasTomlMetadata.ShouldBeTrue();
225215
poemContentImporter.HasYamlMetadata.ShouldBeFalse();
226216
poem.Description.ShouldBe("Est-ce un automne, est-ce un printemps / Qui dans mon cœur se renouvelle");
227-
var anomalies = await poemContentImporter.VerifyAnomaliesAfterImportAsync();
228-
anomalies.ShouldBeEmpty();
217+
poemContentImporter.VerifyAnomaliesAfterImport();
229218
}
230-
231-
}
219+
}

0 commit comments

Comments
 (0)