Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a fixture to setup instant api config builder tests #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions Test/Configuration/InstantAPIsConfigBuilderFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using InstantAPIs;
using Microsoft.EntityFrameworkCore;

namespace Test.Configuration;

public abstract class InstantAPIsConfigBuilderFixture : BaseFixture
{
internal InstantAPIsConfigBuilder<MyContext> _Builder;

public InstantAPIsConfigBuilderFixture()
{

var _ContextOptions = new DbContextOptionsBuilder<MyContext>()
.UseInMemoryDatabase("TestDb")
.Options;
_Builder = new(new(_ContextOptions));

}
}
23 changes: 2 additions & 21 deletions Test/Configuration/WhenIncludeDoesNotSpecifyBaseUrl.cs
Original file line number Diff line number Diff line change
@@ -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<MyContext> _Builder;

public WhenIncludeDoesNotSpecifyBaseUrl()
{

var _ContextOptions = new DbContextOptionsBuilder<MyContext>()
.UseInMemoryDatabase("TestDb")
.Options;
_Builder = new(new(_ContextOptions));

}

[Fact]
public void ShouldSpecifyDefaultUrl()
{
Expand All @@ -35,8 +20,4 @@ public void ShouldSpecifyDefaultUrl()
Assert.Equal(new Uri("/api/Contacts", uriKind: UriKind.Relative), config.Tables.First().BaseUrl);

}


}


29 changes: 2 additions & 27 deletions Test/Configuration/WhenIncludeSpecifiesBaseUrl.cs
Original file line number Diff line number Diff line change
@@ -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<MyContext> _Builder;

public WhenIncludeSpecifiesBaseUrl()
{

var _ContextOptions = new DbContextOptionsBuilder<MyContext>()
.UseInMemoryDatabase("TestDb")
.Options;
_Builder = new(new(_ContextOptions));

}

[Fact]
public void ShouldSpecifyThatUrl()
{
Expand All @@ -42,8 +21,4 @@ public void ShouldSpecifyThatUrl()
Assert.Equal(BaseUrl, config.Tables.First().BaseUrl);

}


}


19 changes: 2 additions & 17 deletions Test/Configuration/WithIncludesAndExcludes.cs
Original file line number Diff line number Diff line change
@@ -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<MyContext> _Builder;

public WithIncludesAndExcludes()
{

var _ContextOptions = new DbContextOptionsBuilder<MyContext>()
.UseInMemoryDatabase("TestDb")
.Options;
_Builder = new(new(_ContextOptions));

}

[Fact]
public void ShouldExcludePreviouslyIncludedTable()
Expand All @@ -39,4 +25,3 @@ public void ShouldExcludePreviouslyIncludedTable()
}

}

21 changes: 2 additions & 19 deletions Test/Configuration/WithOnlyExcludes.cs
Original file line number Diff line number Diff line change
@@ -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<MyContext> _Builder;

public WithOnlyExcludes()
{

var _ContextOptions = new DbContextOptionsBuilder<MyContext>()
.UseInMemoryDatabase("TestDb")
.Options;
_Builder = new(new(_ContextOptions));

}

[Fact]
public void ShouldExcludeSpecifiedTable()
{
Expand Down Expand Up @@ -52,4 +36,3 @@ public void ShouldThrowAnErrorIfAllTablesExcluded()
}

}

21 changes: 1 addition & 20 deletions Test/Configuration/WithOnlyIncludes.cs
Original file line number Diff line number Diff line change
@@ -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<MyContext> _Builder;

public WithOnlyIncludes()
{

var _ContextOptions = new DbContextOptionsBuilder<MyContext>()
.UseInMemoryDatabase("TestDb")
.Options;
_Builder = new(new(_ContextOptions));

}

[Fact]
public void ShouldNotIncludeAllTables()
{
Expand Down
1 change: 0 additions & 1 deletion Test/Configuration/WithoutIncludes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,3 @@ public void ShouldIncludeAllTables()
}

}