diff --git a/src/Queryology.Tests/QueryBaseExtensionsTests.cs b/src/Queryology.Tests/QueryBaseExtensionsTests.cs index 41d217e..e95c6e1 100644 --- a/src/Queryology.Tests/QueryBaseExtensionsTests.cs +++ b/src/Queryology.Tests/QueryBaseExtensionsTests.cs @@ -2,13 +2,20 @@ using System.Collections.Generic; using System.Linq; using ByteDecoder.Queryology.Extensions; -using ByteDecoder.Queryology.Tests.Queries; +using ByteDecoder.Queryology.Tests.TestBuilders; using Xunit; namespace ByteDecoder.Queryology.Tests { - public class QueryBaseExtensionsTests + public class QueryBaseExtensionsTests: IDisposable { + private TestBuilderFactory _testBuilderFactory; + + public QueryBaseExtensionsTests() + { + _testBuilderFactory = new TestBuilderFactory(); + } + [Fact] public void IgnoreExcludedQueries_ThrowsAnArgumentNullException_WhenSourceIsNull() { @@ -25,12 +32,7 @@ public void IgnoreExcludedQueries_FiltersOnlyAllowedQueries_WhenIsSetToTrue() { // Arrange using var dbContext = new NullDbContext(); - var queries = new List>() - { - new QueryTypeNullDbContextOne(dbContext), - new QueryTypeNullDbContextTwo(dbContext), - new QueryTypeNullDbContextThree(dbContext) - }; + var queries = _testBuilderFactory.CreateNullDbContextObjectQueries(dbContext); // Act var result = queries.IgnoreExcludedQueries().Count(); @@ -44,12 +46,7 @@ public void IgnoreExcludedQueries_NoFiltersQueries_WhenIsSetToFalse() { // Arrange using var dbContext = new NullDbContext(); - var queries = new List>() - { - new QueryTypeNullDbContextOne(dbContext), - new QueryTypeNullDbContextTwo(dbContext), - new QueryTypeNullDbContextThree(dbContext) - }; + var queries = _testBuilderFactory.CreateNullDbContextObjectQueries(dbContext); // Act var result = queries.IgnoreExcludedQueries(false).Count(); @@ -57,5 +54,7 @@ public void IgnoreExcludedQueries_NoFiltersQueries_WhenIsSetToFalse() // Assert Assert.Equal(3, result); } + + public void Dispose() => _testBuilderFactory = null; } } \ No newline at end of file diff --git a/src/Queryology.Tests/TestBuilders/TestBuilderFactory.cs b/src/Queryology.Tests/TestBuilders/TestBuilderFactory.cs index 9cb4517..ef3036f 100644 --- a/src/Queryology.Tests/TestBuilders/TestBuilderFactory.cs +++ b/src/Queryology.Tests/TestBuilders/TestBuilderFactory.cs @@ -1,4 +1,6 @@ -using Microsoft.EntityFrameworkCore; +using System.Collections.Generic; +using ByteDecoder.Queryology.Tests.Queries; +using Microsoft.EntityFrameworkCore; namespace ByteDecoder.Queryology.Tests.TestBuilders { @@ -8,5 +10,13 @@ internal class TestBuilderFactory { return new QueryologyEngineTestBuilder(); } + + public IEnumerable> CreateNullDbContextObjectQueries(NullDbContext dbContext) => + new List>() + { + new QueryTypeNullDbContextOne(dbContext), + new QueryTypeNullDbContextTwo(dbContext), + new QueryTypeNullDbContextThree(dbContext) + }; } }