Skip to content

Commit

Permalink
- Multi Map Management #9 (pfh59#302)
Browse files Browse the repository at this point in the history
- Multi Map Management #9 
  - remove usued using
  - reindent
  - add new service EveMapperRealTimeService
  - and new componentmap
  - update to donet 8.0.8
  - fix migration : add alter table
 -  fix WHNote for multimap
 -  fix routeplanner for multimap
 - Delete old add system force
 - Use New Search System dialogue
- add authorization policy for map and control map loading
-  fix and add testunit
- Add tooltip for route planner button
- Update realtime service to manage multi map and access events
- Fix user connected and disconnected by map
- Fix copy /paste sig and notes
  • Loading branch information
pfh59 authored Sep 26, 2024
1 parent 3c8b793 commit ded05ce
Show file tree
Hide file tree
Showing 141 changed files with 7,054 additions and 2,770 deletions.
6 changes: 2 additions & 4 deletions src/WHMapper.Tests/Models/Graph/EveEntityModelTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Pipelines.Sockets.Unofficial.Arenas;
using WHMapper.Models.DTO.EveAPI.Alliance;
using WHMapper.Models.DTO.EveAPI.Alliance;
using WHMapper.Models.DTO.EveAPI.Character;
using WHMapper.Models.DTO.EveAPI.Corporation;
using WHMapper.Models.DTO.EveMapper.Enums;
Expand All @@ -9,7 +7,7 @@

namespace WHMapper.Tests.Models.Graph
{

[TestCaseOrderer(PriorityOrderer.Name, PriorityOrderer.Assembly)]

public class EveEntityModelTest
Expand Down
5 changes: 2 additions & 3 deletions src/WHMapper.Tests/Models/Graph/GraphModelsTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Blazor.Diagrams.Core.Models;
using WHMapper.Models.Custom.Node;
using WHMapper.Models.Custom.Node;
using WHMapper.Models.Db;
using WHMapper.Models.Db.Enums;
using WHMapper.Models.DTO.EveMapper;
Expand Down Expand Up @@ -53,7 +52,7 @@ public GraphModelsTest()
[Fact]
public async Task Eve_System_Node_Model()
{
var node = new EveSystemNodeModel(new WHSystem(DEFAULT_MAP_ID,SOLAR_SYSTEM_JITA_ID, SOLAR_SYSTEM_JITA_NAME, SOLAR_SYSTEM_EXTENSION_NAME, SOLAR_SYSTEM_JITA_SECURITY), new WHNote(SOLAR_SYSTEM_JITA_ID,WHSystemStatus.Friendly,SOLAR_SYSTEM_JITA_NAME), REGION_JITA_NAME, CONSTELLATION_JITA_NAME);
var node = new EveSystemNodeModel(new WHSystem(DEFAULT_MAP_ID,SOLAR_SYSTEM_JITA_ID, SOLAR_SYSTEM_JITA_NAME, SOLAR_SYSTEM_EXTENSION_NAME, SOLAR_SYSTEM_JITA_SECURITY), new WHNote(DEFAULT_MAP_ID,SOLAR_SYSTEM_JITA_ID,WHSystemStatus.Friendly,SOLAR_SYSTEM_JITA_NAME), REGION_JITA_NAME, CONSTELLATION_JITA_NAME);
Assert.NotNull(node);
Assert.Equal(0, node.IdWH);
Assert.Equal(DEFAULT_MAP_ID, node.IdWHMap);
Expand Down
71 changes: 71 additions & 0 deletions src/WHMapper.Tests/Models/MapAdminTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.Collections.Generic;
using WHMapper.Models.Db;
using WHMapper.Models.DTO.MapAdmin;
using Xunit;


namespace WHMapper.Tests.Models;


public class MapAdminTests
{
[Fact]
public void Constructor_ShouldInitializeProperties()
{
// Arrange
var whMap = new WHMap("Test Map");
whMap.Id = 1;
whMap.WHAccesses.Add(new WHAccess(1,"Test Access"));

// Act
var mapAdmin = new MapAdmin(whMap);

// Assert
Assert.Equal(1, mapAdmin.Id);
Assert.Equal("Test Map", mapAdmin.Name);
Assert.NotNull(mapAdmin.WHMapAccesses);
Assert.Single(mapAdmin.WHMapAccesses);
Assert.False(mapAdmin.ShowAccessDetails);
}

[Fact]
public void Constructor_ShouldHandleNullWHMap()
{
// Act
var mapAdmin = new MapAdmin(null);

// Assert
Assert.Equal(-1, mapAdmin.Id);
Assert.Equal(string.Empty, mapAdmin.Name);
Assert.Null(mapAdmin.WHMapAccesses);
Assert.False(mapAdmin.ShowAccessDetails);
}

[Fact]
public void ShowAccessDetails_ShouldBeFalseByDefault()
{
// Arrange
var whMap = new WHMap("Test Map");

// Act
var mapAdmin = new MapAdmin(whMap);

// Assert
Assert.False(mapAdmin.ShowAccessDetails);
}

[Fact]
public void ShowAccessDetails_ShouldBeSettable()
{
// Arrange
var whMap = new WHMap("Test Map");
var mapAdmin = new MapAdmin(whMap);

// Act
mapAdmin.ShowAccessDetails = true;

// Assert
Assert.True(mapAdmin.ShowAccessDetails);
}
}

148 changes: 128 additions & 20 deletions src/WHMapper.Tests/Services/Db/DbIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
using WHMapper.Repositories.WHSystems;

using Xunit.Priority;
using static MudBlazor.CategoryTypes;

namespace WHMapper.Tests.Services;

Expand Down Expand Up @@ -131,29 +130,47 @@ public async Task CRUD_WHMAP()
resByBadId = await repo.GetById(-10);
Assert.Null(resByBadId);

//getByName
var resByName = await repo.GetByNameAsync(FOOBAR);
Assert.NotNull(resByName);
Assert.Equal(FOOBAR, resByName?.Name);

//bad getByName
var resBadName = await repo.GetByNameAsync(FOOBAR_UPDATED);
Assert.Null(resBadName);


//update
resultById1.Name = FOOBAR_UPDATED;
var resultUpdate1 = await repo.Update(resultById1.Id, resultById1);
Assert.NotNull(resultUpdate1);
Assert.Equal(FOOBAR_UPDATED, resultUpdate1.Name);

//bad update
var resultUpdateBad = await repo.Update(-10, resultById1);
Assert.Null(resultUpdateBad);

//update dupkicate
resultById2.Name = FOOBAR_UPDATED;
var resultUpdate2 = await repo.Update(resultById2.Id, resultById2);
Assert.Null(resultUpdate2);


//Delete WHMAP
Assert.NotNull(result1);
var resultDelete1 = await repo.DeleteById(result1.Id);
Assert.True(resultDelete1);

Assert.NotNull(result2);
var resultDelete2 = await repo.DeleteById(result2.Id);
Assert.True(resultDelete2);

var resBadDelete = await repo.DeleteById(-10);
Assert.False(resBadDelete);

//delete all
var resultDeleteAll = await repo.DeleteAll();
Assert.True(resultDeleteAll);

//nothing to delete all
var resultDeleteAll2 = await repo.DeleteAll();
Assert.False(resultDeleteAll2);
}

[Fact, Priority(3)]
Expand Down Expand Up @@ -584,6 +601,15 @@ public async Task CRUD_WHAdmin()
public async Task CRUD_WHAccess()
{
Assert.NotNull(_contextFactory);
//init MAP
//Create IWHMapRepository
IWHMapRepository repoMap = new WHMapRepository(new NullLogger<WHMapRepository>(),_contextFactory);

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

//Create AccessRepo
IWHAccessRepository repo = new WHAccessRepository(new NullLogger<WHAccessRepository>(),_contextFactory);

Expand Down Expand Up @@ -641,20 +667,62 @@ public async Task CRUD_WHAccess()
Assert.Null(resultUpdate2);

//Delete
var resultdel1 = await repo.DeleteById(result1.Id);
Assert.True(resultdel1);

var resultdel2 = await repo.DeleteById(result2.Id);
Assert.True(resultdel2);

var resultBaddel = await repo.DeleteById(-10);
Assert.False(resultBaddel);

//map access
var mapAccess = await repoMap.GetMapAccesses(map.Id);
Assert.NotNull(mapAccess);
Assert.Empty(mapAccess);

//add access to map
var resultAddMapAccess = await repoMap.AddMapAccess(map.Id, result1.Id);
Assert.True(resultAddMapAccess);


Assert.NotNull(map);
mapAccess = await repoMap.GetMapAccesses(map.Id);
Assert.NotNull(mapAccess);
Assert.NotEmpty(mapAccess);

//delete access from map
var resultDelMapAccess = await repoMap.DeleteMapAccess(map.Id, result1.Id);
Assert.True(resultDelMapAccess);

//delete all access from map
var resultDelMapAccesses = await repoMap.DeleteMapAccesses(map.Id);
Assert.True(resultDelMapAccesses);

//dfelete bad access from map
var resultDelBadMapAccess = await repoMap.DeleteMapAccess(-10, result1.Id);
Assert.False(resultDelBadMapAccess);

//Delete WHMAP
var mapDeleted = await repoMap.DeleteById(map.Id);
Assert.True(mapDeleted);

//Delete Access
var resultdel1 = await repo.DeleteById(result1.Id);
Assert.True(resultdel1);

}

[Fact, Priority(8)]
public async Task CRUD_WHNote()
{
Assert.NotNull(_contextFactory);
//init MAP
//Create IWHMapRepository
IWHMapRepository repoMap = new WHMapRepository(new NullLogger<WHMapRepository>(),_contextFactory);

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

//Create AccessRepo
IWHNoteRepository repo = new WHNoteRepository(new NullLogger<WHNoteRepository>(), _contextFactory);

Expand All @@ -664,21 +732,22 @@ public async Task CRUD_WHNote()
Assert.Empty(results);

//ADD Note1
var result1 = await repo.Create(new WHNote(FOOBAR_SYSTEM_ID,FOOBAR));
Assert.NotNull(map);
var result1 = await repo.Create(new WHNote(map.Id,FOOBAR_SYSTEM_ID,FOOBAR));
Assert.NotNull(result1);
Assert.Equal(FOOBAR_SYSTEM_ID, result1.SoloarSystemId);
Assert.Equal(FOOBAR, result1.Comment);
Assert.Equal(WHSystemStatus.Unknown, result1.SystemStatus);

//ADD Note2
var result2 = await repo.Create(new WHNote(FOOBAR_SYSTEM_ID2,WHSystemStatus.Hostile));
var result2 = await repo.Create(new WHNote(map.Id,FOOBAR_SYSTEM_ID2,WHSystemStatus.Hostile));
Assert.NotNull(result2);
Assert.Equal(FOOBAR_SYSTEM_ID2, result2.SoloarSystemId);
Assert.Equal(string.Empty, result2.Comment);
Assert.Equal(WHSystemStatus.Hostile,result2.SystemStatus);

//ADD Access dupkicate
var resultDuplicate = await repo.Create(new WHNote(FOOBAR_SYSTEM_ID2, FOOBAR));
var resultDuplicate = await repo.Create(new WHNote(map.Id,FOOBAR_SYSTEM_ID2, FOOBAR));
Assert.Null(resultDuplicate);

//GetALL
Expand All @@ -696,16 +765,15 @@ public async Task CRUD_WHNote()
var resultBadById = await repo.GetById(-10);
Assert.Null(resultBadById);

//GetBySolarSystemId
var resultBySolarSystemId = await repo.GetBySolarSystemId(FOOBAR_SYSTEM_ID);
//Get
var resultBySolarSystemId = await repo.Get(map.Id,FOOBAR_SYSTEM_ID);
Assert.NotNull(resultBySolarSystemId);
Assert.Equal(FOOBAR_SYSTEM_ID, resultBySolarSystemId.SoloarSystemId);
Assert.Equal(FOOBAR, resultBySolarSystemId.Comment);

var resultBadBySolarSystemId = await repo.GetBySolarSystemId(-10);
var resultBadBySolarSystemId = await repo.Get(map.Id,-10);
Assert.Null(resultBadBySolarSystemId);


//update
result1.Comment = FOOBAR_SHORT_UPDATED;
var resultUpdate1 = await repo.Update(result1.Id, result1);
Expand Down Expand Up @@ -734,12 +802,25 @@ public async Task CRUD_WHNote()
//bad id update
var resultUpdateBadId = await repo.Update(-10, result1);
Assert.Null(resultUpdateBadId);

//Delete WHMAP
var mapDeleted = await repoMap.DeleteById(map.Id);
Assert.True(mapDeleted);
}

[Fact, Priority(9)]
public async Task CRUD_WHRoute()
{
Assert.NotNull(_contextFactory);
//init MAP
//Create IWHMapRepository
IWHMapRepository repoMap = new WHMapRepository(new NullLogger<WHMapRepository>(),_contextFactory);

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

//Create AccessRepo
IWHRouteRepository repo = new WHRouteRepository(new NullLogger<WHRouteRepository>(), _contextFactory);

Expand All @@ -749,20 +830,21 @@ public async Task CRUD_WHRoute()
Assert.Empty(results);

//ADD Route1
var result1 = await repo.Create(new WHRoute(FOOBAR_SYSTEM_ID));
Assert.NotNull(map);
var result1 = await repo.Create(new WHRoute(map.Id,FOOBAR_SYSTEM_ID));
Assert.NotNull(result1);
Assert.Equal(FOOBAR_SYSTEM_ID, result1.SolarSystemId);
Assert.Null(result1.EveEntityId);

//ADD Route2
var result2 = await repo.Create(new WHRoute(FOOBAR_SYSTEM_ID2, EVE_CORPO_ID));
var result2 = await repo.Create(new WHRoute(map.Id,FOOBAR_SYSTEM_ID2, EVE_CORPO_ID));
Assert.NotNull(result2);
Assert.Equal(FOOBAR_SYSTEM_ID2, result2.SolarSystemId);
Assert.Equal(EVE_CORPO_ID, result2.EveEntityId);


//ADD Route dupLicate
var resultDuplicate = await repo.Create(new WHRoute(FOOBAR_SYSTEM_ID2, EVE_CORPO_ID));
var resultDuplicate = await repo.Create(new WHRoute(map.Id,FOOBAR_SYSTEM_ID2, EVE_CORPO_ID));
Assert.Null(resultDuplicate);

//GetALL
Expand Down Expand Up @@ -801,13 +883,13 @@ public async Task CRUD_WHRoute()
Assert.False(resultBaddel);

//ADD Route1 with eveentityid
var result = await repo.Create(new WHRoute(FOOBAR_SYSTEM_ID, EVE_CHARACTERE_ID));
var result = await repo.Create(new WHRoute(map.Id,FOOBAR_SYSTEM_ID, EVE_CHARACTERE_ID));
Assert.NotNull(result);
Assert.Equal(FOOBAR_SYSTEM_ID, result1.SolarSystemId);
Assert.Equal(EVE_CHARACTERE_ID,result1.EveEntityId);

//get by eveentityid
var resultByEveEntityId = await repo.GetRoutesByEveEntityId(EVE_CHARACTERE_ID);
var resultByEveEntityId = await repo.GetRoutesByEveEntityId(map.Id,EVE_CHARACTERE_ID);
Assert.NotNull(resultByEveEntityId);
Assert.NotEmpty(resultByEveEntityId);

Expand All @@ -823,6 +905,10 @@ public async Task CRUD_WHRoute()
var resultdel = await repo.DeleteById(result.Id);
Assert.True(resultdel);

//Delete WHMAP
var mapDeleted = await repoMap.DeleteById(map.Id);
Assert.True(mapDeleted);

}

[Fact, Priority(10)]
Expand Down Expand Up @@ -919,5 +1005,27 @@ public async Task CRUD_WHJumpLog()
//clean map
var mapDeleted = await repoMap.DeleteById(map.Id);
}

[Fact, Priority(12)]
public async Task CRUD_WHJumpMassLog()
{
Assert.NotNull(_contextFactory);

//init MAP
//Create IWHMapRepository
IWHMapRepository repoMap = new WHMapRepository(new NullLogger<WHMapRepository>(),_contextFactory);

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








}
Loading

0 comments on commit ded05ce

Please sign in to comment.