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

Last fixes #109

Merged
merged 11 commits into from
Aug 5, 2023
Merged
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
5 changes: 3 additions & 2 deletions .github/workflows/ci-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup JDK 11 🦴
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 1.11
distribution: 'oracle'
java-version: 17

- name: Setup .NET7 🦴
uses: actions/setup-dotnet@v2
Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore


#unzip SDE ressources
Resources/SDE/universe/

# User-specific files
*.rsuser
*.suo
Expand All @@ -15,6 +12,11 @@ Resources/SDE/universe/
*.sln.docstates
.vs
.DS_Store
**/appsettings.Development.json
**/appsettings.Production.json
#unzip SDE ressources
**/Resources/SDE/universe/


# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# eve-whmapper [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![GitHub top language](https://img.shields.io/github/languages/top/pfh59/eve-whmapper) ![GitHub language count](https://img.shields.io/github/languages/count/pfh59/eve-whmapper) [![Continous Integration and Deployement](https://github.com/pfh59/eve-whmapper/actions/workflows/ci-cd.yaml/badge.svg)](https://github.com/pfh59/eve-whmapper/actions/workflows/ci-cd.yaml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pfh59_eve-whmapper&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=pfh59_eve-whmapper) ![GitHub commit activity (main)](https://img.shields.io/github/commit-activity/m/pfh59/eve-whmapper) ![GitLab tag (self-managed)](https://img.shields.io/gitlab/v/tag/eve-whmapper)
# <img src="WHMapper/wwwroot/favicon.ico" width="32" heigth="32"> EvE-WHMapper
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ![GitHub top language](https://img.shields.io/github/languages/top/pfh59/eve-whmapper) ![GitHub language count](https://img.shields.io/github/languages/count/pfh59/eve-whmapper) [![Continous Integration and Deployement](https://github.com/pfh59/eve-whmapper/actions/workflows/ci-cd.yaml/badge.svg)](https://github.com/pfh59/eve-whmapper/actions/workflows/ci-cd.yaml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=pfh59_eve-whmapper&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=pfh59_eve-whmapper) ![GitHub commit activity (main)](https://img.shields.io/github/commit-activity/m/pfh59/eve-whmapper) ![GitLab tag (self-managed)](https://img.shields.io/gitlab/v/tag/eve-whmapper)


## Description
Expand Down Expand Up @@ -156,7 +157,7 @@ sudo ./stop.sh

<div align="center">

[![view - Documentation](https://img.shields.io/badge/view-Documentation-blue?style=for-the-badge)](/docs/ "Go to project documentation")
[![view - Documentation](https://img.shields.io/badge/view-Documentation-blue?style=for-the-badge)](/docs/index.md "Go to project documentation")

</div>

Expand Down
53 changes: 31 additions & 22 deletions WHMapper.Tests/Db/DbIntegrationTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.EntityFrameworkCore;
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using WHMapper.Data;
using WHMapper.Models.Db;
using WHMapper.Models.Db.Enums;
Expand Down Expand Up @@ -31,9 +33,10 @@ public class DbIntegrationTest

private const int FOOBAR_SYSTEM_ID2 = 1234567;
private const string FOOBAR_SHORT_UPDATED = "FooBarU";
private WHMapperContext _context;
private IDbContextFactory<WHMapperContext> _contextFactory;




public DbIntegrationTest()
{
//Create DB Context
Expand All @@ -42,30 +45,36 @@ public DbIntegrationTest()
.AddEnvironmentVariables()
.Build();

var optionBuilder = new DbContextOptionsBuilder<WHMapperContext>();
optionBuilder.UseNpgsql(configuration["ConnectionStrings:DefaultConnection"]);
var services = new ServiceCollection();
services.AddDbContextFactory<WHMapperContext>(options =>
options.UseNpgsql(configuration.GetConnectionString("DefaultConnection")));

var provider = services.BuildServiceProvider();
_contextFactory = provider.GetService<IDbContextFactory<WHMapperContext>>();

_context = new WHMapperContext(optionBuilder.Options);
}



[Fact, Priority(1)]
public async Task DeleteAndCreateDatabse()
{
//Delete all to make a fresh Db
bool dbDeleted = await _context.Database.EnsureDeletedAsync();
Assert.True(dbDeleted);
bool dbCreated = await _context.Database.EnsureCreatedAsync();
Assert.True(dbCreated);
using (var context = _contextFactory.CreateDbContext())
{
//Delete all to make a fresh Db
bool dbDeleted = await context.Database.EnsureDeletedAsync();
Assert.True(dbDeleted);
bool dbCreated = await context.Database.EnsureCreatedAsync();
Assert.True(dbCreated);
}

}

[Fact, Priority(2)]
public async Task CRUD_WHMAP()
{
//Create IWHMapRepository
IWHMapRepository repo = new WHMapRepository(_context);
IWHMapRepository repo = new WHMapRepository(_contextFactory);

//ADD WHMAP
var result = await repo.Create(new WHMap(FOOBAR));
Expand Down Expand Up @@ -99,15 +108,15 @@ public async Task CRUD_WHSystem()
{
//init MAP
//Create IWHMapRepository
IWHMapRepository repoMap = new WHMapRepository(_context);
IWHMapRepository repoMap = new WHMapRepository(_contextFactory);

//ADD WHMAP
var map = await repoMap.Create(new WHMap(FOOBAR));
Assert.NotNull(map);
Assert.Equal(FOOBAR, map?.Name);

//Create IWHMapRepository
IWHSystemRepository repo = new WHSystemRepository(_context);
IWHSystemRepository repo = new WHSystemRepository(_contextFactory);


//GETALL system => return empty arry
Expand Down Expand Up @@ -173,7 +182,7 @@ public async Task CRUD_WHLink()
{
//init MAP
//Create IWHMapRepository
IWHMapRepository repoMap = new WHMapRepository(_context);
IWHMapRepository repoMap = new WHMapRepository(_contextFactory);

//ADD WHMAP
var map = await repoMap.Create(new WHMap(FOOBAR));
Expand All @@ -182,7 +191,7 @@ public async Task CRUD_WHLink()


//Create IWHMapRepository
IWHSystemRepository repoWH = new WHSystemRepository(_context);
IWHSystemRepository repoWH = new WHSystemRepository(_contextFactory);
Assert.NotNull(map);
var whSys1 = await repoWH.Create(new WHSystem(map.Id,FOOBAR_SYSTEM_ID, FOOBAR, 1));
Assert.NotNull(whSys1);
Expand All @@ -201,7 +210,7 @@ public async Task CRUD_WHLink()


//Create IWHMapRepository
IWHSystemLinkRepository repo = new WHSystemLinkRepository(_context);
IWHSystemLinkRepository repo = new WHSystemLinkRepository(_contextFactory);

//add whsystem link
var link = await repo.Create(new WHSystemLink(map.Id,whSys1.Id, whSys2.Id));
Expand Down Expand Up @@ -249,7 +258,7 @@ public async Task CRUD_WHSignature()
{
//init MAP
//Create IWHMapRepository
IWHMapRepository repoMap = new WHMapRepository(_context);
IWHMapRepository repoMap = new WHMapRepository(_contextFactory);

//ADD WHMAP
var map = await repoMap.Create(new WHMap(FOOBAR));
Expand All @@ -258,7 +267,7 @@ public async Task CRUD_WHSignature()


//Create IWHMapRepository
IWHSystemRepository repoWH = new WHSystemRepository(_context);
IWHSystemRepository repoWH = new WHSystemRepository(_contextFactory);
Assert.NotNull(map);
var whSys1 = await repoWH.Create(new WHSystem(map.Id, FOOBAR_SYSTEM_ID, FOOBAR, 1));
Assert.NotNull(whSys1);
Expand All @@ -269,7 +278,7 @@ public async Task CRUD_WHSignature()


//Create IWHMapRepository
IWHSignatureRepository repo = new WHSignatureRepository(_context);
IWHSignatureRepository repo = new WHSignatureRepository(_contextFactory);

//ADD WHSignature
var result = await repo.Create(new WHSignature(whSys1.Id,FOOBAR));
Expand Down Expand Up @@ -356,7 +365,7 @@ public async Task CRUD_WHSignature()
public async Task CRUD_WHAdmin()
{
//Create IWHMapRepository
IWHAdminRepository repo = new WHAdminRepository(_context);
IWHAdminRepository repo = new WHAdminRepository(_contextFactory);

//ADD WHMAP
var result = await repo.Create(new WHAdmin(EVE_CHARACTERE_ID, "TOTO"));
Expand Down Expand Up @@ -390,7 +399,7 @@ public async Task CRUD_WHAdmin()
public async Task CRUD_WHAccess()
{
//Create IWHMapRepository
IWHAccessRepository repo = new WHAccessRepository(_context);
IWHAccessRepository repo = new WHAccessRepository(_contextFactory);

//ADD WHMAP
var result = await repo.Create(new WHAccess(EVE_CORPO_ID,"TOTO", WHAccessEntity.Corporation));
Expand Down
16 changes: 8 additions & 8 deletions WHMapper.Tests/SDE/SDEUniverseTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,39 +29,39 @@ public SDEUniverseTest()
}

[Fact]
public void Search_System()
public async void Search_System()
{
//TEST empty
var empty_result = _services.SearchSystem("");
var empty_result = await _services.SearchSystem("");
Assert.Null(empty_result);
//TEST JITA
var jita_result = _services.SearchSystem(SOLAR_SYSTEM_JITA_NAME);
var jita_result = await _services.SearchSystem(SOLAR_SYSTEM_JITA_NAME);
Assert.NotNull(jita_result);
Assert.Single(jita_result);

//TEST JI for JITA partial
var ji_result = _services.SearchSystem(SOLAR_SYSTEM_JIT_NAME);
var ji_result = await _services.SearchSystem(SOLAR_SYSTEM_JIT_NAME);
Assert.NotNull(ji_result);
Assert.Contains(ji_result, x => x.Name.Contains(SOLAR_SYSTEM_JITA_NAME, StringComparison.OrdinalIgnoreCase));


//TEST AMARR
var amarr_result = _services.SearchSystem(SOLAR_SYSTEM_AMARR_NAME);
var amarr_result = await _services.SearchSystem(SOLAR_SYSTEM_AMARR_NAME);
Assert.NotNull(amarr_result);
Assert.Single(amarr_result);

//TEST AMA for AMARR partial
var ama_result = _services.SearchSystem(SOLAR_SYSTEM_AMA_NAME);
var ama_result = await _services.SearchSystem(SOLAR_SYSTEM_AMA_NAME);
Assert.NotNull(ama_result);
Assert.Contains(ama_result, x => x.Name.Contains(SOLAR_SYSTEM_AMARR_NAME, StringComparison.OrdinalIgnoreCase));


//TEST WH
var wh_result = _services.SearchSystem(SOLAR_SYSTEM_WH_NAME);
var wh_result = await _services.SearchSystem(SOLAR_SYSTEM_WH_NAME);
Assert.NotNull(wh_result);
Assert.Single(wh_result);

var wh_partial_result = _services.SearchSystem(SOLAR_SYSTEM_WH_PARTIAL_NAME);
var wh_partial_result = await _services.SearchSystem(SOLAR_SYSTEM_WH_PARTIAL_NAME);
Assert.NotNull(wh_partial_result);
Assert.Contains(wh_partial_result, x => x.Name.Contains(SOLAR_SYSTEM_WH_NAME, StringComparison.OrdinalIgnoreCase));

Expand Down
40 changes: 24 additions & 16 deletions WHMapper.Tests/WHHelper/EveWHAccessHelperTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -27,32 +28,35 @@ public class EveWHAccessHelperTest
private int EVE_CORPO_ID = 1344654522;
private int EVE_ALLIANCE_ID = 1354830081;

private WHMapperContext _context;
IDbContextFactory<WHMapperContext> _contextFactory;
private IEveMapperAccessHelper _accessHelper;
private IWHAccessRepository _whAccessRepository;
private IWHAdminRepository _whAdminRepository;



public EveWHAccessHelperTest()
{

var services = new ServiceCollection();
services.AddHttpClient();
var provider = services.BuildServiceProvider();
var httpclientfactory = provider.GetService<IHttpClientFactory>();


//Create DB Context
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddEnvironmentVariables()
.Build();

var optionBuilder = new DbContextOptionsBuilder<WHMapperContext>();
optionBuilder.UseNpgsql(configuration["ConnectionStrings:DefaultConnection"]);
var services = new ServiceCollection();
services.AddDbContextFactory<WHMapperContext>(options =>
options.UseNpgsql(configuration.GetConnectionString("DefaultConnection")));

_context = new WHMapperContext(optionBuilder.Options);
_whAccessRepository = new WHAccessRepository(_context);
_whAdminRepository = new WHAdminRepository(_context);
services.AddHttpClient();

var provider = services.BuildServiceProvider();
var httpclientfactory = provider.GetService<IHttpClientFactory>();


_contextFactory = provider.GetService<IDbContextFactory<WHMapperContext>>();
_whAccessRepository = new WHAccessRepository(_contextFactory);
_whAdminRepository = new WHAdminRepository(_contextFactory);
_accessHelper = new EveMapperAccessHelper(_whAccessRepository,_whAdminRepository, new CharacterServices(httpclientfactory.CreateClient()));


Expand All @@ -62,10 +66,14 @@ public EveWHAccessHelperTest()
public async Task Delete_And_Create_DB()
{
//Delete all to make a fresh Db
bool dbDeleted = await _context.Database.EnsureDeletedAsync();
Assert.True(dbDeleted);
bool dbCreated = await _context.Database.EnsureCreatedAsync();
Assert.True(dbCreated);

using (var context = _contextFactory.CreateDbContext())
{
bool dbDeleted = await context.Database.EnsureDeletedAsync();
Assert.True(dbDeleted);
bool dbCreated = await context.Database.EnsureCreatedAsync();
Assert.True(dbCreated);
}

}

Expand Down
4 changes: 2 additions & 2 deletions WHMapper.Tests/WHHelper/WHSignatureHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class WHSignatureHelperTest
{
private const int WH_ID = 1;
private const string SCAN_USER = "FOOBAR";
private const string DSCAN = "IGU-360\tCosmic Signature\t\t\t0,0%\t37,21 AU\nRNN-835\tCosmic Signature\t\t\t0,0%\t21,98 AU\nETT-010\tCosmic Signature\t\t\t0,0%\t27,03 AU\nHBO-538\tCosmic Signature\t\t\t0,0%\t38,17 AU\nOBF-800\tCosmic Signature\t\t\t0,0%\t35,48 AU\nBNU-740\tCosmic Signature\t\t\t0,0%\t34,86 AU\nAWU-108\tCosmic Signature\tGas Site\t\t0,0%\t26,19 AU\nDXY-229\tCosmic Signature\tGas Site\tSizeable Perimeter Reservoir\t100,0%\t28,07 AU\nQBJ-502\tCosmic Signature\tRelic Site\tRuined Guristas Monument Site\t100,0%\t25,45 AU\nXQX-010\tCosmic Signature\tWormhole\tUnstable Wormhole\t100,0%\t23,50 AU";
private const string DSCAN = "IGU-360\tCosmic Signature\t\t\t0,0%\t37,21 AU\nWAM-436\tCosmic Signature\tWormhole\tUnstable Wormhole\t100,0%\t101 km\nRNN-835\tCosmic Signature\t\t\t0,0%\t21,98 AU\nETT-010\tCosmic Signature\t\t\t0,0%\t27,03 AU\nHBO-538\tCosmic Signature\t\t\t0,0%\t38,17 AU\nOBF-800\tCosmic Signature\t\t\t0,0%\t35,48 AU\nBNU-740\tCosmic Signature\t\t\t0,0%\t34,86 AU\nAWU-108\tCosmic Signature\tGas Site\t\t0,0%\t26,19 AU\nDXY-229\tCosmic Signature\tGas Site\tSizeable Perimeter Reservoir\t100,0%\t28,07 AU\nQBJ-502\tCosmic Signature\tRelic Site\tRuined Guristas Monument Site\t100,0%\t25,45 AU\nXQX-010\tCosmic Signature\tWormhole\tUnstable Wormhole\t100,0%\t23,50 AU";
private const string FIRST_SIG_NAME = "IGU-360";
private const string LAST_SIG_NAME = "XQX-010";
private const string UNSTABLE_WORMHOLE = "Unstable Wormhole";
Expand Down Expand Up @@ -46,7 +46,7 @@ public async Task Parse_Scan_Result_Test()

var parseDSCAN1= await _whHelper.ParseScanResult(SCAN_USER, WH_ID,DSCAN);
Assert.NotEmpty(parseDSCAN1);
Assert.Equal(10, parseDSCAN1.Count());
Assert.Equal(11, parseDSCAN1.Count());

var firstSig = parseDSCAN1.First();

Expand Down
6 changes: 0 additions & 6 deletions WHMapper.Tests/WHMapper.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<None Remove="Npgsql.EntityFrameworkCore.PostgreSQL" />
<None Remove="Npgsql" />
<None Remove="appsettings.json" />
<None Remove="appsettings.Development.json" />
<None Remove="Microsoft.Extensions.Configuration" />
<None Remove="Orders\" />
<None Remove="EveOnlineAPI\" />
Expand All @@ -52,11 +51,6 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.Development.json" Condition="'$(ExcludeConfigFilesFromBuildOutput)'!='true'">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WHMapper\WHMapper.csproj" />
Expand Down
17 changes: 0 additions & 17 deletions WHMapper.Tests/appsettings.Development.json

This file was deleted.

4 changes: 2 additions & 2 deletions WHMapper.Tests/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"AllowedHosts": "*",
"EveSSO": {
"Domain": "login.eveonline.com",
"ClientId": "39eee319b2d14a4a9ba3e9eb1b1410b8",
"Secret": "Qg5uFfjYcqhvrw6FdXhxTMHM9yxNBBb8N3BYGvCN",
"ClientId": "",
"Secret": "",
"DefaultScopes": [
"esi-location.read_location.v1",
"esi-location.read_ship_type.v1",
Expand Down
Binary file removed WHMapper/.DS_Store
Binary file not shown.
Loading