Skip to content

Commit

Permalink
Merge pull request #14 from eulynx-live/DegradedPointPosition
Browse files Browse the repository at this point in the history
Simulate Degraded Point Positions
  • Loading branch information
rs22 authored Nov 20, 2023
2 parents 1b0cec0 + 89d2e0e commit 59d9f5e
Show file tree
Hide file tree
Showing 24 changed files with 1,812 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore src/${{ matrix.subsystem }}
- name: Build
Expand Down
19 changes: 19 additions & 0 deletions .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: dotnet test

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore src/FieldElementSubsystems.Test
- name: Test
run: dotnet test --no-restore src/FieldElementSubsystems.Test
7 changes: 7 additions & 0 deletions Subsystems.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainDetectionSystem", "src
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProtobufInterfaces", "src\ProtobufInterfaces\ProtobufInterfaces.csproj", "{965CC255-F89B-4FB5-9E21-3740C0CEDEE6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FieldElementSubsystems.Test", "src\FieldElementSubsystems.Test\FieldElementSubsystems.Test.csproj", "{8585AF02-898B-4D21-94EA-17EB71EF3ADD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -50,6 +52,10 @@ Global
{965CC255-F89B-4FB5-9E21-3740C0CEDEE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{965CC255-F89B-4FB5-9E21-3740C0CEDEE6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{965CC255-F89B-4FB5-9E21-3740C0CEDEE6}.Release|Any CPU.Build.0 = Release|Any CPU
{8585AF02-898B-4D21-94EA-17EB71EF3ADD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8585AF02-898B-4D21-94EA-17EB71EF3ADD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8585AF02-898B-4D21-94EA-17EB71EF3ADD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8585AF02-898B-4D21-94EA-17EB71EF3ADD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{BCBCDBD2-4E04-4C1D-A79E-40C4B6ED38DE} = {1146C126-94F3-476E-BADE-E40B22C98FA5}
Expand All @@ -58,5 +64,6 @@ Global
{01B16178-39DD-4279-B7AF-C74D816619E7} = {1146C126-94F3-476E-BADE-E40B22C98FA5}
{767D8926-579F-4508-9CBC-3B46AA0ACE3D} = {1146C126-94F3-476E-BADE-E40B22C98FA5}
{965CC255-F89B-4FB5-9E21-3740C0CEDEE6} = {1146C126-94F3-476E-BADE-E40B22C98FA5}
{8585AF02-898B-4D21-94EA-17EB71EF3ADD} = {1146C126-94F3-476E-BADE-E40B22C98FA5}
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions docker/Point/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM mcr.microsoft.com/dotnet/aspnet:6.0
FROM mcr.microsoft.com/dotnet/aspnet:7.0

COPY src/Point/bin/Release/net6.0/publish/ app/
COPY src/Point/bin/Release/net7.0/publish/ app/

WORKDIR /app

Expand Down
30 changes: 30 additions & 0 deletions src/FieldElementSubsystems.Test/FieldElementSubsystems.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.1" />
<PackageReference Include="Moq" Version="4.20.69" />
<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.2.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Point\Point.csproj" />
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/FieldElementSubsystems.Test/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
31 changes: 31 additions & 0 deletions src/FieldElementSubsystems.Test/Point/PointTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Castle.Core.Logging;
using EulynxLive.Messages.Baseline4R1;
using EulynxLive.Point;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Moq;
namespace FieldElementSubsystems.Test;

public class PointTest
{
[Fact]
public void PointShouldParseConfiguration()
{
var testSettings = new Dictionary<string, string?> {
{"PointSettings:LocalId", "99W1" },
{"PointSettings:LocalRastaId", "100" },
{"PointSettings:RemoteId", "INTERLOCKING" },
{"PointSettings:RemoteEndpoint", "http://localhost:50051" },
{"PointSettings:AllPointMachinesCrucial", "true" },
{"PointSettings:SimulateRandomTimeouts", "true" },
};

var configuration = new ConfigurationBuilder()
.AddInMemoryCollection(testSettings)
.Build();

var point = new EulynxLive.Point.Point(Mock.Of<ILogger<EulynxLive.Point.Point>>(), configuration);

Assert.True(point.AllPointMachinesCrucial);
}
}
5 changes: 3 additions & 2 deletions src/Point/Components/PointMachine/PointMachineState.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using ReportedPointPosition = EulynxLive.Messages.Baseline4R1.PointPointPositionMessageReportedPointPosition;
using ReportedDegradedPointPosition = EulynxLive.Messages.Baseline4R1.PointPointPositionMessageReportedDegradedPointPosition;
using PointMachineStateMessage = EulynxLive.Point.Proto.PointMachineStateMessage.Types;

namespace EulynxLive.Point.Components
{
public class PointMachineState
{
public ReportedPointPosition PointPosition { get; set; }
public ReportedDegradedPointPosition DegradedPointPosition { get; set; }
public PointMachineStateMessage.Target Target { get; set; }
public PointMachineStateMessage.AbilityToMove AbilityToMove { get; set; }
public PointMachineStateMessage.LastPointPosition LastPointPosition { get; set; }
public PointMachineStateMessage.Crucial Crucial { get; set; }
}
}
}
Loading

0 comments on commit 59d9f5e

Please sign in to comment.