Skip to content

Commit

Permalink
test: Use assertion called WithInnerException
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDave1999 committed Dec 11, 2023
1 parent 8321217 commit 657815b
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions tests/Loader/YeSqlLoaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,13 @@ public void LoadFromFiles_WhenErrorsAreFound_ShouldThrowAggregateException()
// Act
Action action = () => loader.LoadFromFiles(files);

// Asserts
action.Should()
.Throw<YeSqlLoaderException>()
.WithMessage(string.Join(Environment.NewLine, expectedLoaderErrors));

// Assert
action.Should()
.Throw<YeSqlParserException>()
.Throw<AggregateException>()
.WithInnerException<YeSqlLoaderException>()
.WithMessage(string.Join(Environment.NewLine, expectedLoaderErrors))
.WithInnerException<YeSqlParserException>()
.WithMessage(string.Join(Environment.NewLine, expectedParserErrors));

action.Should().Throw<AggregateException>();
}

[Test]
Expand Down Expand Up @@ -82,12 +79,11 @@ public void LoadFromFiles_WhenFileHasNotSqlExtension_ShouldThrowAggregateExcepti
// Act
Action action = () => loader.LoadFromFiles(file);

// Asserts
// Assert
action.Should()
.Throw<YeSqlLoaderException>()
.Throw<AggregateException>()
.WithInnerException<YeSqlLoaderException>()
.WithMessage(expectedMessage);

action.Should().Throw<AggregateException>();
}

[Test]
Expand All @@ -101,12 +97,11 @@ public void LoadFromFiles_WhenSqlFileNotExists_ShouldThrowAggregateException()
// Act
Action action = () => loader.LoadFromFiles(file);

// Asserts
// Assert
action.Should()
.Throw<YeSqlLoaderException>()
.Throw<AggregateException>()
.WithInnerException<YeSqlLoaderException>()
.WithMessage(expectedMessage);

action.Should().Throw<AggregateException>();
}

[TestCase("")]
Expand Down Expand Up @@ -174,16 +169,13 @@ public void LoadFromDirectories_WhenErrorsAreFound_ShouldThrowAggregateException
// Act
Action action = () => loader.LoadFromDirectories(directories);

// Asserts
action.Should()
.Throw<YeSqlLoaderException>()
.WithMessage(string.Join(Environment.NewLine, expectedLoaderErrors));

// Assert
action.Should()
.Throw<YeSqlParserException>()
.Throw<AggregateException>()
.WithInnerException<YeSqlLoaderException>()
.WithMessage(string.Join(Environment.NewLine, expectedLoaderErrors))
.WithInnerException<YeSqlParserException>()
.WithMessage(string.Join(Environment.NewLine, expectedParserErrors));

action.Should().Throw<AggregateException>();
}

[Test]
Expand Down Expand Up @@ -230,12 +222,11 @@ public void LoadFromDirectories_WhenNotExistsSqlFilesInDirectory_ShouldThrowAggr
// Act
Action action = () => loader.LoadFromDirectories(directory);

// Asserts
// Assert
action.Should()
.Throw<YeSqlLoaderException>()
.Throw<AggregateException>()
.WithInnerException<YeSqlLoaderException>()
.WithMessage(expectedMessage);

action.Should().Throw<AggregateException>();
}

[Test]
Expand Down Expand Up @@ -265,10 +256,9 @@ public void LoadFromDirectories_WhenDirectoryNotExists_ShouldThrowAggregateExcep

// Asserts
action.Should()
.Throw<YeSqlLoaderException>()
.Throw<AggregateException>()
.WithInnerException<YeSqlLoaderException>()
.WithMessage(expectedMessage);

action.Should().Throw<AggregateException>();
}

[Test]
Expand Down

0 comments on commit 657815b

Please sign in to comment.