Skip to content
This repository has been archived by the owner on Oct 22, 2023. It is now read-only.

Commit

Permalink
Added support for setting the SteamId of the mocked contract through …
Browse files Browse the repository at this point in the history
…appsettings.json
  • Loading branch information
LennardF1989 committed Jul 15, 2023
1 parent 262f48e commit a42ab81
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Src/HM5.Server/Controllers/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected JsonResult JsonGenericResponse<T>(T data)
}

/**
* NOTE: Even though it is not constrained, only use primitive values for the generic!
* NOTE: Even though it is not constrained, only use primitive types for the generic!
*/
protected JsonResult JsonOperationValueResponse<T>(T data)
{
Expand All @@ -36,7 +36,7 @@ protected JsonResult JsonOperationValueResponse<T>(T data)
}

/**
* NOTE: Even though it is not constrained, only use primitive values for the generic!
* NOTE: Even though it is not constrained, only use primitive types for the generic!
*/
protected JsonResult JsonOperationListResponse<T>(List<T> data)
{
Expand Down
20 changes: 15 additions & 5 deletions Src/HM5.Server/Controllers/Hitman/HitmanController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class BaseGetAverageScoresRequest : IEdmFunctionImport
public const string SchemaNamespace = "HM5";

//NOTE: Rating seems unused in UI?
private readonly List<ScoreEntry> _mockedGetScoresResponse = new()
private static readonly List<ScoreEntry> _mockedGetScoresResponse = new()
{
new ScoreEntry
{
Expand Down Expand Up @@ -76,15 +76,15 @@ public abstract class BaseGetAverageScoresRequest : IEdmFunctionImport
}
};

private readonly List<int> _mockedGetAverageScoresResponse = new()
private static readonly List<int> _mockedGetAverageScoresResponse = new()
{
1, //World Average
2, //Country Average
3, //Friends Average
4 //Score: Deadliest / Richest / Most Popular Assassin
};

private readonly Contract _mockedContractWithoutCompetition = new()
private static readonly Contract _mockedContractWithoutCompetition = new()
{
Id = 1,
DisplayId = "FakeContract47",
Expand Down Expand Up @@ -136,7 +136,7 @@ public abstract class BaseGetAverageScoresRequest : IEdmFunctionImport
UserScore = 241953
};

private readonly Contract _mockedContractWithCompetition = new()
private static readonly Contract _mockedContractWithCompetition = new()
{
Id = 2,
DisplayId = "FakeContract48",
Expand Down Expand Up @@ -208,11 +208,21 @@ public abstract class BaseGetAverageScoresRequest : IEdmFunctionImport

public HitmanController(
ISimpleLogger simpleLogger,
IMetadataServiceForHitman metadataService
IMetadataServiceForHitman metadataService,
Options options
)
: base(simpleLogger)
{
_metadataService = metadataService;

//Apply options to the mocked contracts
_mockedContractWithoutCompetition.UserId = options.MockedContractSteamId;
_mockedContractWithoutCompetition.HighestScoringFriendName = options.MockedContractSteamId;

_mockedContractWithCompetition.UserId = options.MockedContractSteamId;
_mockedContractWithCompetition.CompetitionLeader = options.MockedContractSteamId;
_mockedContractWithCompetition.HighestScoringFriendName = options.MockedContractSteamId;
_mockedContractWithCompetition.Competition.Competition[0].CompetitionCreator = options.MockedContractSteamId;
}

public static List<Type> GetEdmEntityTypes()
Expand Down
1 change: 1 addition & 0 deletions Src/HM5.Server/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class Options
public bool EnableRequestLogging { get; set; } = false;
public bool EnableRequestBodyLogging { get; set; } = false;
public bool EnableResponseBodyLogging { get; set; } = false;
public string MockedContractSteamId { get; set; } = "76561198161220058";
}
}
24 changes: 24 additions & 0 deletions Src/HM5.Server/Properties/PublishProfiles/FolderProfile.pubxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>false</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>..\..\Bin\Publish</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<ProjectGuid>6fa95780-4890-46c7-9342-c5cc7e465eef</ProjectGuid>
<SelfContained>true</SelfContained>
</PropertyGroup>
</Project>
13 changes: 12 additions & 1 deletion Src/HM5.Server/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
{
"Kestrel": {
"Endpoints": {
"Http": {
"Url": "http://localhost:80"
},
"Https": {
"Url": "https://localhost:443"
}
}
},
"Options": {
"FixAddMetricsContentType": true,
"EnableRequestLogging": true,
"EnableRequestBodyLogging": true,
"EnableResponseBodyLogging": true
"EnableResponseBodyLogging": true,
"MockedContractSteamId": "76561198161220058"
}
}

0 comments on commit a42ab81

Please sign in to comment.