Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Pipeline/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ partial class Build : NukeBuild
/// <para />
/// Afterward, you can update the package reference in `Directory.Packages.props` and reset this flag.
/// </summary>
readonly BuildScope BuildScope = BuildScope.Default;
readonly BuildScope BuildScope = BuildScope.CoreOnly;

[Parameter("Github Token")] readonly string GithubToken;
[GitRepository] readonly GitRepository Repository;
Expand Down
2 changes: 0 additions & 2 deletions Source/aweXpect.Core/Core/ResultContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace aweXpect.Core;
/// </summary>
public abstract class ResultContext
{
internal ResultContext? _next;

/// <summary>
/// A result context that is appended to a result error.
/// </summary>
Expand Down
46 changes: 5 additions & 41 deletions Source/aweXpect.Core/Core/ResultContexts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,12 @@ namespace aweXpect.Core;
/// </summary>
public class ResultContexts : IEnumerable<ResultContext>
{
private ResultContext? _first;
private readonly List<ResultContext> _results = new();
private bool _isOpen = true;

/// <inheritdoc cref="IEnumerable{ResultContext}.GetEnumerator()" />
public IEnumerator<ResultContext> GetEnumerator()
{
ResultContext? current = _first;
while (current != null)
{
yield return current;
current = current._next;
}
}
=> _results.GetEnumerator();

/// <inheritdoc cref="IEnumerable.GetEnumerator()" />
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
Expand Down Expand Up @@ -51,15 +44,7 @@ public ResultContexts Add(ResultContext context)
{
if (_isOpen)
{
if (_first is null)
{
_first = context;
}
else
{
context._next = _first;
_first = context;
}
_results.Add(context);
}

return this;
Expand All @@ -72,7 +57,7 @@ public ResultContexts Clear()
{
if (_isOpen)
{
_first = null;
_results.Clear();
}

return this;
Expand All @@ -91,28 +76,7 @@ public ResultContexts Remove(Predicate<ResultContext> predicate)
{
if (_isOpen)
{
ResultContext? previous = null;
ResultContext? current = _first;
while (current != null)
{
if (predicate(current))
{
if (previous == null)
{
_first = current._next;
}
else
{
previous._next = current._next;
}
}
else
{
previous = current;
}

current = current._next;
}
_results.RemoveAll(predicate);
}

return this;
Expand Down
3 changes: 3 additions & 0 deletions Tests/aweXpect.Core.Tests/Core/Nodes/WhichNodeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,9 @@ Expected that subject

Actual:
foo

Expected:
bar
""");
}

Expand Down
17 changes: 16 additions & 1 deletion Tests/aweXpect.Core.Tests/Core/ResultContextsTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace aweXpect.Core.Tests.Core;
using System.Collections.Generic;
using System.Linq;

namespace aweXpect.Core.Tests.Core;

public sealed class ResultContextsTests
{
Expand Down Expand Up @@ -29,6 +32,18 @@ public async Task AddMultiple_ShouldAddContext()
await That(sut).HasCount().EqualTo(5);
}

[Fact]
public async Task AddSameContextMultipleTimes_ShouldStillWork()
{
var sharedContext = new ResultContext.Fixed("foo", "1");
ResultContexts sut = new();
sut.Add(sharedContext);
sut.Add(sharedContext);
sut.Add(sharedContext);

await That(sut).All().ComplyWith(x => x.IsSameAs(sharedContext));
}

[Fact]
public async Task Clear_ShouldRemoveAllContexts()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ Expected that actual

Actual:
this is some text with lots of words after the first difference to verify the customization setting

Expected:
this is another text with lots of words after the first difference to verify the customization setting
""");
}

Expand All @@ -88,6 +91,9 @@ Expected that actual

Actual:
this is some text with lots of words after the first difference to verify the customization setting

Expected:
this is another text with lots of words after the first difference to verify the customization setting
""");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Expected that sut
Actual:
foo
bar

Expected:
FOO
BAR
""").IgnoringNewlineStyle();
}

Expand All @@ -62,6 +66,9 @@ Expected that sut

Actual:
foo

Expected:
bar
""");
}

Expand All @@ -86,6 +93,10 @@ Expected that sut
Actual:
foo
bar

Expected:
something
else
""").IgnoringNewlineStyle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Expected that sut
Actual:
foo
bar

Expected:
FOO
BAR
""").IgnoringNewlineStyle();
}

Expand All @@ -62,6 +66,9 @@ Expected that sut

Actual:
foo

Expected:
bar
""");
}

Expand All @@ -86,6 +93,10 @@ Expected that sut
Actual:
foo
bar

Expected:
something
else
""").IgnoringNewlineStyle();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Expected that sut
Actual:
foo
bar

Expected:
FOO
BAR
""").IgnoringNewlineStyle();
}

Expand All @@ -62,6 +66,9 @@ Expected that sut

Actual:
foo

Expected:
bar
""");
}

Expand All @@ -86,6 +93,10 @@ Expected that sut
Actual:
foo
bar

Expected:
something
else
""").IgnoringNewlineStyle();
}

Expand Down
Loading