Skip to content

Commit

Permalink
Testing Sdk updated
Browse files Browse the repository at this point in the history
  • Loading branch information
ByteDecoder committed Aug 28, 2024
1 parent 100fb69 commit 0c6591a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Queryology.Tests/Queryology.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<CodeAnalysisRuleSet>..\_stylecop\StyleCopRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
9 changes: 9 additions & 0 deletions src/Queryology.Tests/Support/TestObjectViewer.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
namespace ByteDecoder.Queryology.Tests.Support
{
/// <summary>
/// Provides methods to display data for unit testing.
/// </summary>
public static class TestObjectViewer
{
/// <summary>
/// Displays the specified data with the given title and depth.
/// </summary>
/// <param name="title">The title of the data.</param>
/// <param name="data">The data to be displayed.</param>
/// <param name="depth">The depth of the data.</param>
public static void DisplayData(string title, object data, int depth)
{
// Just empty method for fast unit testing
Expand Down
23 changes: 23 additions & 0 deletions src/Queryology.Tests/TestBuilders/QueryologyEngineTestBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@

namespace ByteDecoder.Queryology.Tests.TestBuilders
{
/// <summary>
/// Represents a test builder for QueryologyEngine.
/// </summary>
/// <typeparam name="T">The type of the DbContext.</typeparam>
internal class QueryologyEngineTestBuilder<T> : IDisposable
where T : DbContext, new()
{
private T _dbContext;
private IQueryologyEngine<T> _queryologyEngine;
private bool _disposedValue;

/// <summary>
/// Initializes a new instance of the <see cref="QueryologyEngineTestBuilder{T}"/> class.
/// </summary>
public QueryologyEngineTestBuilder()
{
_dbContext = new T();
Expand All @@ -22,23 +29,39 @@ public QueryologyEngineTestBuilder()
}).Build();
}

/// <summary>
/// Specifies that excluded queries should not be ignored.
/// </summary>
/// <returns>The current instance of the <see cref="QueryologyEngineTestBuilder{T}"/>.</returns>
public QueryologyEngineTestBuilder<T> NotIgnoreExcludedQueries()
{
_queryologyEngine.IgnoreExcludedQueries(false);
return this;
}

/// <summary>
/// Specifies that excluded queries should be ignored.
/// </summary>
/// <returns>The current instance of the <see cref="QueryologyEngineTestBuilder{T}"/>.</returns>
public QueryologyEngineTestBuilder<T> IgnoreExcludedQueries()
{
_queryologyEngine.IgnoreExcludedQueries(true);
return this;
}

/// <summary>
/// Builds and returns an instance of the <see cref="IQueryologyEngine{T}"/>.
/// </summary>
/// <returns>An instance of the <see cref="IQueryologyEngine{T}"/>.</returns>
public IQueryologyEngine<T> Build()
{
return _queryologyEngine;
}

/// <summary>
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
/// </summary>
/// <param name="disposing">True if called from the `Dispose` method, false if called from the finalizer.</param>
protected virtual void Dispose(bool disposing)
{
if (_disposedValue)
Expand Down

0 comments on commit 0c6591a

Please sign in to comment.