Skip to content
Merged
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
18 changes: 18 additions & 0 deletions tests/Wolfgang.TryPattern.Tests.Unit/ResultTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ public void Flatten_when_array_contains_null_element_throws_ArgumentException()



[Fact]
public void Flatten_when_null_appears_after_first_failure_throws_ArgumentException()
{
// Regression test for the second null-check inside Flatten's
// tail loop (Result.cs:172). The pre-existing test covers a
// null seen before the first failure (head loop). This one
// covers a null seen AFTER the first failure — the tail loop
// must keep validating elements even after firstFailureIndex
// is set, else a trailing null would silently ride along
// into the flattened Result.
var ex = Assert.Throws<ArgumentException>(() =>
Result.Flatten(Result.Failure("first"), null!, Result.Success()));
Assert.Equal("results", ex.ParamName);
Assert.Contains("index 1", ex.Message, StringComparison.Ordinal);
}



[Fact]
public void AllSucceeded_when_array_contains_null_element_throws_ArgumentException()
{
Expand Down