-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9c646de
commit 3cff959
Showing
11 changed files
with
194 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" /> | ||
<PackageReference Include="xunit" Version="2.4.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="3.1.2"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Artin.BringAuto\Artin.BringAuto.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Artin.BringAuto.DAL.Models; | ||
using Artin.BringAuto.Test.Cars.Integrations.Fixtures; | ||
using BringAuto.Server.Repositories; | ||
using Microsoft.EntityFrameworkCore; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Artin.BringAuto.Test.Cars.Integrations.Cars | ||
{ | ||
public class CarControllerTest : IClassFixture<CarFixture> | ||
{ | ||
private readonly CarFixture _fixture; | ||
private readonly DbSet<Car> _entities; | ||
private const string _modelRoute = "api/v1/cars"; | ||
|
||
public CarControllerTest(CarFixture fixture) | ||
{ | ||
_fixture = fixture; | ||
_entities = _fixture.DbContext.Set<Car>(); | ||
} | ||
|
||
[Fact] | ||
public void IsKnownCar_Not_Undertest_Test() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Artin.BringAuto.Test.Cars.Integrations.Fixtures | ||
{ | ||
public class CarFixture : TestFixture | ||
{ | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
using Artin.BringAuto.DAL; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Artin.BringAuto.Test | ||
{ | ||
public class TestFixture : IDisposable | ||
{ | ||
public const string USERNAME = "j.hodic@fingood.cz"; | ||
public const string PASSWORD = "Abc123456789"; | ||
private readonly IServiceProvider _services; | ||
|
||
public HttpClient HttpClient { get; set; } | ||
public BringAutoDbContext DbContext { get; private set; } | ||
/* | ||
public TestFixture() | ||
{ | ||
var hostBuilder = new HostBuilder() | ||
.ConfigureWebHost(webHost => | ||
{ | ||
// Add TestServer | ||
webHost.UseTestServer() | ||
.UseStartup<Startup>() | ||
.UseEnvironment(Environments.Development) | ||
.UseConfiguration(new ConfigurationBuilder() | ||
.AddJsonFile("appsettings.Development.json") | ||
.Build() | ||
); | ||
// configure the services after the startup has been called. | ||
webHost.ConfigureTestServices(services => | ||
{ | ||
// register the test one specifically | ||
services.SwapSqLiteDbContext<BringAutoDbContext>(); | ||
SetServices(services); | ||
}); | ||
}); | ||
var host = hostBuilder.Start(); | ||
_services = host.Services; | ||
HttpClient = host.GetTestClient(); | ||
DbContext = GetService<IDbContextResolver>().GetContext() as BringAutoDbContext; | ||
// Init DB | ||
CreateDatabase(); | ||
} | ||
public void ReloadContext() | ||
{ | ||
DbContext = new BringAutoDbContext(GetService<DbContextOptions<BringAutoDbContext>>()); | ||
} | ||
*/ | ||
public virtual void CreateDatabase() | ||
=> DbContext.Database.EnsureCreated(); | ||
|
||
public IServiceProvider GetServices() => _services; | ||
public T GetService<T>() => (T)_services.GetService(typeof(T)); | ||
|
||
protected virtual void SetServices(IServiceCollection serviceCollection) { } | ||
|
||
public void Dispose() | ||
{ | ||
Dispose(true); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
protected virtual void Dispose(bool disposing) | ||
{ | ||
if (disposing) | ||
{ | ||
if (HttpClient != null) | ||
{ | ||
HttpClient.Dispose(); | ||
HttpClient = null; | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
namespace Artin.Bringauto.Test | ||
{ | ||
public class UnitTest1 | ||
{ | ||
[Fact] | ||
public void Test1() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |