diff --git a/Test/Configuration/InstantAPIsConfigBuilderFixture.cs b/Test/Configuration/InstantAPIsConfigBuilderFixture.cs new file mode 100644 index 0000000..84b1c62 --- /dev/null +++ b/Test/Configuration/InstantAPIsConfigBuilderFixture.cs @@ -0,0 +1,19 @@ +using InstantAPIs; +using Microsoft.EntityFrameworkCore; + +namespace Test.Configuration; + +public abstract class InstantAPIsConfigBuilderFixture : BaseFixture +{ + internal InstantAPIsConfigBuilder _Builder; + + public InstantAPIsConfigBuilderFixture() + { + + var _ContextOptions = new DbContextOptionsBuilder() + .UseInMemoryDatabase("TestDb") + .Options; + _Builder = new(new(_ContextOptions)); + + } +} diff --git a/Test/Configuration/WhenIncludeDoesNotSpecifyBaseUrl.cs b/Test/Configuration/WhenIncludeDoesNotSpecifyBaseUrl.cs index 0acaa0c..a9e21ff 100644 --- a/Test/Configuration/WhenIncludeDoesNotSpecifyBaseUrl.cs +++ b/Test/Configuration/WhenIncludeDoesNotSpecifyBaseUrl.cs @@ -1,25 +1,10 @@ -using InstantAPIs; -using Microsoft.AspNetCore.Builder; -using Microsoft.EntityFrameworkCore; -using Xunit; +using Xunit; namespace Test.Configuration; -public class WhenIncludeDoesNotSpecifyBaseUrl : BaseFixture +public class WhenIncludeDoesNotSpecifyBaseUrl : InstantAPIsConfigBuilderFixture { - InstantAPIsConfigBuilder _Builder; - - public WhenIncludeDoesNotSpecifyBaseUrl() - { - - var _ContextOptions = new DbContextOptionsBuilder() - .UseInMemoryDatabase("TestDb") - .Options; - _Builder = new(new(_ContextOptions)); - - } - [Fact] public void ShouldSpecifyDefaultUrl() { @@ -35,8 +20,4 @@ public void ShouldSpecifyDefaultUrl() Assert.Equal(new Uri("/api/Contacts", uriKind: UriKind.Relative), config.Tables.First().BaseUrl); } - - } - - diff --git a/Test/Configuration/WhenIncludeSpecifiesBaseUrl.cs b/Test/Configuration/WhenIncludeSpecifiesBaseUrl.cs index ef4ed08..c2e113f 100644 --- a/Test/Configuration/WhenIncludeSpecifiesBaseUrl.cs +++ b/Test/Configuration/WhenIncludeSpecifiesBaseUrl.cs @@ -1,31 +1,10 @@ -using InstantAPIs; -using Microsoft.AspNetCore.Builder; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Xunit; +using Xunit; namespace Test.Configuration; - -public class WhenIncludeSpecifiesBaseUrl : BaseFixture +public class WhenIncludeSpecifiesBaseUrl : InstantAPIsConfigBuilderFixture { - InstantAPIsConfigBuilder _Builder; - - public WhenIncludeSpecifiesBaseUrl() - { - - var _ContextOptions = new DbContextOptionsBuilder() - .UseInMemoryDatabase("TestDb") - .Options; - _Builder = new(new(_ContextOptions)); - - } - [Fact] public void ShouldSpecifyThatUrl() { @@ -42,8 +21,4 @@ public void ShouldSpecifyThatUrl() Assert.Equal(BaseUrl, config.Tables.First().BaseUrl); } - - } - - diff --git a/Test/Configuration/WithIncludesAndExcludes.cs b/Test/Configuration/WithIncludesAndExcludes.cs index dad6b54..4e28530 100644 --- a/Test/Configuration/WithIncludesAndExcludes.cs +++ b/Test/Configuration/WithIncludesAndExcludes.cs @@ -1,24 +1,10 @@ -using InstantAPIs; -using Microsoft.AspNetCore.Builder; -using Microsoft.EntityFrameworkCore; -using Xunit; +using Xunit; namespace Test.Configuration; -public class WithIncludesAndExcludes : BaseFixture +public class WithIncludesAndExcludes : InstantAPIsConfigBuilderFixture { - InstantAPIsConfigBuilder _Builder; - - public WithIncludesAndExcludes() - { - - var _ContextOptions = new DbContextOptionsBuilder() - .UseInMemoryDatabase("TestDb") - .Options; - _Builder = new(new(_ContextOptions)); - - } [Fact] public void ShouldExcludePreviouslyIncludedTable() @@ -39,4 +25,3 @@ public void ShouldExcludePreviouslyIncludedTable() } } - diff --git a/Test/Configuration/WithOnlyExcludes.cs b/Test/Configuration/WithOnlyExcludes.cs index d40c587..df23e5a 100644 --- a/Test/Configuration/WithOnlyExcludes.cs +++ b/Test/Configuration/WithOnlyExcludes.cs @@ -1,26 +1,10 @@ -using InstantAPIs; -using Microsoft.AspNetCore.Builder; -using Microsoft.EntityFrameworkCore; -using System.Linq; -using Xunit; +using Xunit; namespace Test.Configuration; -public class WithOnlyExcludes : BaseFixture +public class WithOnlyExcludes : InstantAPIsConfigBuilderFixture { - InstantAPIsConfigBuilder _Builder; - - public WithOnlyExcludes() - { - - var _ContextOptions = new DbContextOptionsBuilder() - .UseInMemoryDatabase("TestDb") - .Options; - _Builder = new(new(_ContextOptions)); - - } - [Fact] public void ShouldExcludeSpecifiedTable() { @@ -52,4 +36,3 @@ public void ShouldThrowAnErrorIfAllTablesExcluded() } } - diff --git a/Test/Configuration/WithOnlyIncludes.cs b/Test/Configuration/WithOnlyIncludes.cs index 765da73..bc27887 100644 --- a/Test/Configuration/WithOnlyIncludes.cs +++ b/Test/Configuration/WithOnlyIncludes.cs @@ -1,30 +1,11 @@ using InstantAPIs; -using Microsoft.AspNetCore.Builder; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Xunit; namespace Test.Configuration; -public class WithOnlyIncludes : BaseFixture +public class WithOnlyIncludes : InstantAPIsConfigBuilderFixture { - InstantAPIsConfigBuilder _Builder; - - public WithOnlyIncludes() - { - - var _ContextOptions = new DbContextOptionsBuilder() - .UseInMemoryDatabase("TestDb") - .Options; - _Builder = new(new(_ContextOptions)); - - } - [Fact] public void ShouldNotIncludeAllTables() { diff --git a/Test/Configuration/WithoutIncludes.cs b/Test/Configuration/WithoutIncludes.cs index 11e4f1a..5756b36 100644 --- a/Test/Configuration/WithoutIncludes.cs +++ b/Test/Configuration/WithoutIncludes.cs @@ -39,4 +39,3 @@ public void ShouldIncludeAllTables() } } -