Skip to content

Commit

Permalink
Fixed Breaking Unit Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
NikoMix committed Aug 31, 2024
1 parent c83e551 commit f158438
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tests/core/Statiq.Common.Tests/Meta/MetadataFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void ReturnsFalseForInvalidValue()

// Then
Assert.That(contains, Is.False);
Assert.That(value, Is.EquivalentTo(null));
Assert.That(value, Is.Null);
}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task CopyFilesInTopDirectoryOnly()
// Then
Assert.That(context.FileSystem.GetOutputFile("test-a.txt").Exists, Is.True);
Assert.That(context.FileSystem.GetOutputFile("test-b.txt").Exists, Is.True);
Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.True);
Assert.That(context.FileSystem.GetOutputFile("Subfolder/test-c.txt").Exists, Is.False);
Assert.That(context.FileSystem.GetOutputDirectory("Subfolder").Exists, Is.False);
Assert.That(context.FileSystem.GetOutputFile("markdown-x.md").Exists, Is.False);
Assert.That(context.FileSystem.GetOutputFile("Subfolder/markdown-y.md").Exists, Is.False);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ enum Yellow
// Then
results.Single(x => x["Name"].Equals("Green"))["SpecificKind"].ShouldBe("Class");
results.Single(x => x["Name"].Equals("Blue"))["SpecificKind"].ShouldBe("Class");
results.Single(x => x["Name"].Equals("Red"))["SpecificKind"].ShouldBe("Structure");
results.Single(x => x["Name"].Equals("Red"))["SpecificKind"].ShouldBe("Struct");
results.Single(x => x["Name"].Equals("Yellow"))["SpecificKind"].ShouldBe("Enum");
}

Expand Down
34 changes: 17 additions & 17 deletions tests/extensions/Statiq.Handlebars.Tests/RenderHandlebarsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public async Task RendersHandlebarsWithBlockHelper()
{
// Given
const string input = @"{{#each animals}}
The animal, {{name}}, {{StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
The animal, {{name}}, {{#StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
{{/each}}";
const string output = @"The animal, Fluffy, is not a dog.
The animal, Fido, is a dog.
Expand Down Expand Up @@ -324,7 +324,7 @@ public async Task RendersHandlebarsWithBlockHelperUsingConfigure()
{
// Given
const string input = @"{{#each animals}}
The animal, {{name}}, {{StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
The animal, {{name}}, {{#StringEqualityBlockHelper type 'dog'}}is a dog{{else}}is not a dog{{/StringEqualityBlockHelper}}.
{{/each}}";
const string output = @"The animal, Fluffy, is not a dog.
The animal, Fido, is a dog.
Expand All @@ -346,22 +346,22 @@ public async Task RendersHandlebarsWithBlockHelperUsingConfigure()

RenderHandlebars handlebars = new RenderHandlebars()
.Configure((_, __, x) => x.RegisterHelper("StringEqualityBlockHelper", (writer, options, __, arguments) =>
{
if (arguments.Length != 2)
{
if (arguments.Length != 2)
{
throw new HandlebarsException("{{StringEqualityBlockHelper}} helper must have exactly two argument");
}
string left = arguments[0] as string;
string right = arguments[1] as string;
if (left == right)
{
options.Template(writer, null);
}
else
{
options.Inverse(writer, null);
}
}));
throw new HandlebarsException("{{StringEqualityBlockHelper}} helper must have exactly two argument");
}
string left = arguments[0] as string;
string right = arguments[1] as string;
if (left == right)
{
options.Template(writer, null);
}
else
{
options.Inverse(writer, null);
}
}));

// When
TestDocument result = await ExecuteAsync(document, handlebars).SingleAsync();
Expand Down
11 changes: 10 additions & 1 deletion tests/extensions/Statiq.Lunr.Tests/GenerateLunrIndexFixture.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -14,6 +15,14 @@ namespace Statiq.Lunr.Tests
[TestFixture]
public class GenerateLunrIndexFixture : BaseFixture
{
[SetUp]
public void SetUp()
{
// Set the culture to en-US for the tests, otherwise tests with decimals fail on machines with , as decimal seperator
CultureInfo.CurrentCulture = new CultureInfo("en-US");
CultureInfo.CurrentUICulture = new CultureInfo("en-US");
}

public class ExecuteTests : GenerateLunrIndexFixture
{
[Test]
Expand Down Expand Up @@ -541,7 +550,7 @@ public async Task ConvertsSearchableField(object value, string expected)

// Then
TestDocument indexDocument = results.ShouldHaveSingleWithDestination(GenerateLunrIndex.DefaultScriptPath.ChangeExtension(".index.json"));
indexDocument.Content.ShouldContain(expected);
indexDocument.Content.ShouldContainWithoutWhitespace(expected); // ShouldContain is clipped to first 100 chars, but occurrence is beyond. This method is not clipped; Workaround
}

[Test]
Expand Down

0 comments on commit f158438

Please sign in to comment.