Skip to content

Commit

Permalink
First pass (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfh59 committed Jun 24, 2024
1 parent 3d4dcf2 commit 35b213c
Show file tree
Hide file tree
Showing 34 changed files with 479 additions and 530 deletions.
10 changes: 5 additions & 5 deletions src/WHMapper.Tests/Models/Graph/GraphModelsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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,WHSystemStatusEnum.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(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 All @@ -63,7 +63,7 @@ public async Task Eve_System_Node_Model()
Assert.Equal("B", node.NameExtension);
Assert.Empty(node.ConnectedUsers);
Assert.False(node.Locked);
Assert.Equal(WHSystemStatusEnum.Friendly,node.SystemStatus);
Assert.Equal(WHSystemStatus.Friendly,node.SystemStatus);

await node.AddConnectedUser(USERNAME1);
await node.AddConnectedUser(USERNAME2);
Expand All @@ -87,8 +87,8 @@ public async Task Eve_System_Node_Model()
node.DecrementNameExtension();
Assert.Null(node.NameExtension);

node.SystemStatus=WHSystemStatusEnum.Hostile;
Assert.Equal(WHSystemStatusEnum.Hostile,node.SystemStatus);
node.SystemStatus=WHSystemStatus.Hostile;
Assert.Equal(WHSystemStatus.Hostile,node.SystemStatus);

node.Locked=true;
Assert.True(node.Locked);
Expand All @@ -108,7 +108,7 @@ public async Task Eve_System_Node_Model()
public void Eve_System_Link_Model()
{
var node = new EveSystemNodeModel(new WHSystem(DEFAULT_MAP_ID,SOLAR_SYSTEM_JITA_ID, SOLAR_SYSTEM_JITA_NAME, SOLAR_SYSTEM_JITA_SECURITY), null, REGION_JITA_NAME, CONSTELLATION_JITA_NAME);
Assert.Equal(WHSystemStatusEnum.Unknown,node.SystemStatus);
Assert.Equal(WHSystemStatus.Unknown,node.SystemStatus);
var node2 = new EveSystemNodeModel(new WHSystem(DEFAULT_MAP_ID, SOLAR_SYSTEM_WH_ID, SOLAR_SYSTEM_WH_NAME, -1.0F), null, REGION_WH_NAME, CONSTELLATION_WH_NAME,SOLAR_SYSTEM_WH_CLASS, SOLAR_SYSTEM_WH_EFFECT,null, new List<WHStatic>() { new WHStatic(SOLAR_SYSTEM_WH_STATICS,EveSystemType.C3) }) ;


Expand Down
27 changes: 13 additions & 14 deletions src/WHMapper.Tests/Services/Db/DbIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,16 @@ namespace WHMapper.Tests.Services;
[Collection("C2-Services")]
public class DbIntegrationTest
{
private int EVE_CHARACTERE_ID = 2113720458;
private int EVE_CHARACTERE_ID2 = 2113932209;
private string EVE_CHARACTERE_NAME = "TOTO";
private string EVE_CHARACTERE_NAME2 = "TITI";

private int EVE_CORPO_ID = 1344654522;
private string EVE_CORPO_NAME = "Corp1";
private int EVE_CORPO_ID2 = 123456789;
private string EVE_CORPO_NAME2 = "Corp12";

private int EVE_ALLIANCE_ID = 1354830081;
private const int EVE_CHARACTERE_ID = 2113720458;
private const int EVE_CHARACTERE_ID2 = 2113932209;
private const string EVE_CHARACTERE_NAME = "TOTO";
private const string EVE_CHARACTERE_NAME2 = "TITI";

private const int EVE_CORPO_ID = 1344654522;
private const string EVE_CORPO_NAME = "Corp1";
private const int EVE_CORPO_ID2 = 123456789;
private const string EVE_CORPO_NAME2 = "Corp12";
private const int EVE_ALLIANCE_ID = 1354830081;


private const int FOOBAR_SYSTEM_ID = 123456;
Expand Down Expand Up @@ -669,14 +668,14 @@ public async Task CRUD_WHNote()
Assert.NotNull(result1);
Assert.Equal(FOOBAR_SYSTEM_ID, result1.SoloarSystemId);
Assert.Equal(FOOBAR, result1.Comment);
Assert.Equal(WHSystemStatusEnum.Unknown, result1.SystemStatus);
Assert.Equal(WHSystemStatus.Unknown, result1.SystemStatus);

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

//ADD Access dupkicate
var resultDuplicate = await repo.Create(new WHNote(FOOBAR_SYSTEM_ID2, FOOBAR));
Expand Down
10 changes: 8 additions & 2 deletions src/WHMapper.Tests/WHHelper/EveWHMapperHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,18 @@ public EveWHMapperHelperTest()
[Fact, Priority(1)]
public Task Is_Wormhole()
{
bool not_wh_result = _whEveMapper.IsWorhmole(SOLAR_SYSTEM_JITA_NAME);
bool not_wh_result = _whEveMapper.IsWormhole(SOLAR_SYSTEM_JITA_NAME);
Assert.False(not_wh_result);

bool is_wh_result = _whEveMapper.IsWorhmole(SOLAR_SYSTEM_WH_NAME);
bool is_wh_result = _whEveMapper.IsWormhole(SOLAR_SYSTEM_WH_NAME);
Assert.True(is_wh_result);

bool bad_result = _whEveMapper.IsWormhole("BAD_NAME");
Assert.False(bad_result);

bool bad_empty_result = _whEveMapper.IsWormhole(string.Empty);
Assert.False(bad_empty_result);

return Task.CompletedTask;
}

Expand Down
10 changes: 5 additions & 5 deletions src/WHMapper.Tests/WHHelper/WHColorHelperTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ public void Get_Link_Selected_Color()
[Fact]
public void Get_Node_Status_Color()
{
Assert.Equal(NODE_STATUS_FRIENDLY_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatusEnum.Friendly));
Assert.Equal(NODE_STATUS_OCCUPIED_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatusEnum.Occupied));
Assert.Equal(NODE_STATUS_HOSTILE_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatusEnum.Hostile));
Assert.Equal(NODE_STATUS_UNKNOWN_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatusEnum.Unknown));
Assert.Equal(IWHColorHelper.DEFAULT_COLOR, _whHelper.GetNodeStatusColor((WHSystemStatusEnum)28));
Assert.Equal(NODE_STATUS_FRIENDLY_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatus.Friendly));
Assert.Equal(NODE_STATUS_OCCUPIED_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatus.Occupied));
Assert.Equal(NODE_STATUS_HOSTILE_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatus.Hostile));
Assert.Equal(NODE_STATUS_UNKNOWN_COLOR, _whHelper.GetNodeStatusColor(WHSystemStatus.Unknown));
Assert.Equal(IWHColorHelper.DEFAULT_COLOR, _whHelper.GetNodeStatusColor((WHSystemStatus)28));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/WHMapper/Hubs/IWHMapperNotificationHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public interface IWHMapperNotificationHub
Task NotifyWormholeNameExtensionChanged(string username, int mapId, int wormholeId,bool increment);
Task NotifyWormholeSignaturesChanged(string username, int mapId, int wormholeId);
Task NotifyWormholeLockChanged(string username, int mapId, int wormholeId, bool locked);
Task NotifyWormholeSystemStatusChanged(string username, int mapId, int wormholeId, WHSystemStatusEnum systemStatus);
Task NotifyWormholeSystemStatusChanged(string username, int mapId, int wormholeId, WHSystemStatus systemStatus);
}
}

4 changes: 1 addition & 3 deletions src/WHMapper/Hubs/WHMapperNotificationHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public override async Task OnConnectedAsync()

public override async Task OnDisconnectedAsync(Exception? exception)
{
string res = string.Empty;
string userName = CurrentUser();
_connections.Remove(userName, Context.ConnectionId);

Expand Down Expand Up @@ -78,7 +77,6 @@ public async Task SendUserPosition(string systemName)
}

await Clients.AllExcept(Context.ConnectionId).NotifyUserPosition(userName, systemName);
//await Clients.Caller.NotifyUsersPosition(_connectedUserPosition);
}

public async Task SendWormholeAdded(int mapId, int wowrmholeId)
Expand Down Expand Up @@ -165,7 +163,7 @@ public async Task SendWormholeLockChanged(int mapId, int wormholeId, bool locked
}
}

public async Task SendWormholeSystemStatusChanged(int mapId, int wormholeId, WHSystemStatusEnum systemStatus)
public async Task SendWormholeSystemStatusChanged(int mapId, int wormholeId, WHSystemStatus systemStatus)
{
string userName = CurrentUser();
if (!string.IsNullOrEmpty(userName))
Expand Down
10 changes: 5 additions & 5 deletions src/WHMapper/Models/Custom/Node/EveSystemNodeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class EveSystemNodeModel : NodeModel

private readonly WHSystem _wh;

private WHSystemStatusEnum _systemStatus;
private WHSystemStatus _systemStatus;

public int IdWH
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public new bool Locked

}

public WHSystemStatusEnum SystemStatus
public WHSystemStatus SystemStatus
{
get
{
Expand All @@ -112,7 +112,7 @@ public WHSystemStatusEnum SystemStatus
public string RegionName { get; private set; }
public string ConstellationName { get; private set;}

public EveSystemType SystemType { get; private set; } = EveSystemType.None;
public EveSystemType SystemType { get; private set; }
public WHEffect Effect { get; private set; } = WHEffect.None;
public IList<EveSystemEffect>? EffectDetails { get; private set; } = null!;
public IList<WHStatic>? Statics { get; private set; } = null!;
Expand All @@ -127,7 +127,7 @@ public EveSystemNodeModel(WHSystem wh, WHNote? note, string regionName, string c
if(note != null)
_systemStatus = note.SystemStatus;
else
_systemStatus=WHSystemStatusEnum.Unknown;
_systemStatus=WHSystemStatus.Unknown;

RegionName = regionName;
ConstellationName = constellationName;
Expand All @@ -151,7 +151,7 @@ public EveSystemNodeModel(WHSystem wh, WHNote? note, string regionName, string c
if(note != null)
_systemStatus = note.SystemStatus;
else
_systemStatus=WHSystemStatusEnum.Unknown;
_systemStatus=WHSystemStatus.Unknown;


RegionName = regionName;
Expand Down
4 changes: 2 additions & 2 deletions src/WHMapper/Models/DTO/EveAPI/Assets/Asset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public class Asset
public long ItemId { get; set; }

[JsonPropertyName("location_flag")]
public string LocationFlag { get; set; }
public string? LocationFlag { get; set; }

[JsonPropertyName("location_id")]
public long LocationId { get; set; }

[JsonPropertyName("location_type")]
public string LocationType { get; set; }
public string? LocationType { get; set; }

[JsonPropertyName("quantity")]
public int Quantity { get; set; }
Expand Down
41 changes: 19 additions & 22 deletions src/WHMapper/Models/DTO/EveMapper/Enums/EveSystemTypeEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,27 @@

namespace WHMapper.Models.DTO.EveMapper.Enums
{
public enum EveSystemType
public enum EveSystemType :int
{
HS,
LS,
NS,
HS=7,
LS=8,
NS=9,
[Description("T")]
Pochven,
C1,
C2,
C3,
C4,
C5,
C6,
C13,
C14,
C15,
C16,
C17,
C18,
Thera,
K162,
C123,
C45,
None
Pochven=25,
C1=1,
C2=2,
C3=3,
C4=4,
C5=5,
C6=6,
C13=13,
C14=14,
C15=15,
C16=16,
C17=17,
C18=18,
Thera=12,
None=-1
}

public static class EveSystemTypeExtensions
Expand Down
2 changes: 1 addition & 1 deletion src/WHMapper/Models/Db/Enums/WHSystemStatusEnums.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
namespace WHMapper.Models.Db.Enums
{
public enum WHSystemStatusEnum
public enum WHSystemStatus
{
Unknown,
Friendly,
Expand Down
8 changes: 4 additions & 4 deletions src/WHMapper/Models/Db/WHNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ public class WHNote
[Required, StringLength(255, ErrorMessage = "Comment is too long.")]
public String Comment { get; set; } = string.Empty;

public WHSystemStatusEnum SystemStatus { get; set; } = WHSystemStatusEnum.Unknown;
public WHSystemStatus SystemStatus { get; set; } = WHSystemStatus.Unknown;

[Obsolete("EF Requires it")]
protected WHNote() { }

public WHNote(int soloarSystemId,string comment)
: this(soloarSystemId,WHSystemStatusEnum.Unknown,comment)
: this(soloarSystemId,WHSystemStatus.Unknown,comment)
{

}

public WHNote(int soloarSystemId, WHSystemStatusEnum systemStatus)
public WHNote(int soloarSystemId, WHSystemStatus systemStatus)
:this(soloarSystemId,systemStatus,string.Empty)

{

}

public WHNote(int soloarSystemId, WHSystemStatusEnum systemStatus,string comment)
public WHNote(int soloarSystemId, WHSystemStatus systemStatus,string comment)
{
SoloarSystemId = soloarSystemId;
SystemStatus = systemStatus;
Expand Down
4 changes: 2 additions & 2 deletions src/WHMapper/Pages/Mapper/Administration/Overview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private async Task DeleteAccess(int id)

var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };

var dialog = DialogService.Show<Delete>("Delete WHMapper Access", parameters, options);
var dialog = await DialogService.ShowAsync<Delete>("Delete WHMapper Access", parameters, options);
DialogResult result = await dialog.Result;

if (result!=null && !result.Canceled)
Expand All @@ -196,7 +196,7 @@ private async Task DeleteAdmin(int id)

var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.ExtraSmall };

var dialog = DialogService.Show<Delete>("Delete WHMapper Admin", parameters, options);
var dialog = await DialogService.ShowAsync<Delete>("Delete WHMapper Admin", parameters, options);
DialogResult result = await dialog.Result;

if (result != null && !result.Canceled)
Expand Down
Loading

0 comments on commit 35b213c

Please sign in to comment.