-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Adf doesn't send correct value for 3 digit input and add tests
- Loading branch information
1 parent
788457b
commit 1df03a6
Showing
11 changed files
with
111 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
namespace FlightStreamDeck.Logics | ||
using static FlightStreamDeck.Logics.SimEventManager; | ||
|
||
namespace FlightStreamDeck.Logics | ||
{ | ||
public interface IEventRegistrar | ||
{ | ||
void RegisterEvent(string? eventName); | ||
(EventEnum eventEnum, bool isValid)? RegisterEvent(string? eventName); | ||
void ReInitializeEvents(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
FlightStreamDeck.LogicsTests/Actions/NavCom/AdfHandlerTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using FlightStreamDeck.Logics.Actions.NavCom; | ||
|
||
namespace FlightStreamDeck.Logics.Tests.Actions.NavCom; | ||
|
||
[TestClass] | ||
public class AdfHandlerTests | ||
{ | ||
[TestMethod] | ||
public async Task TestSetAdf1200() | ||
{ | ||
Mock<IFlightConnector> mockFlightConnector = new Mock<IFlightConnector>(); | ||
|
||
var eventManager = new SimEventManager( | ||
new LoggerFactory().CreateLogger<SimEventManager>(), | ||
mockFlightConnector.Object | ||
); | ||
|
||
var registration = eventManager.RegisterEvent(KnownEvents.ADF_STBY_SET.ToString()); | ||
Assert.IsNotNull(registration); | ||
|
||
var adfHandler = new AdfHandler( | ||
mockFlightConnector.Object, | ||
eventManager, | ||
eventManager, | ||
Core.TOGGLE_VALUE.ADF_ACTIVE_FREQUENCY__1, | ||
Core.TOGGLE_VALUE.ADF_STANDBY_FREQUENCY__1, | ||
null, | ||
null, | ||
KnownEvents.ADF1_RADIO_SWAP, | ||
KnownEvents.ADF_STBY_SET | ||
); | ||
|
||
await adfHandler.TriggerAsync("1200", false); | ||
|
||
mockFlightConnector.Verify(connector => connector.Trigger(registration.Value.eventEnum, 301989888)); | ||
} | ||
|
||
[TestMethod] | ||
public async Task TestSetAdf120() | ||
{ | ||
Mock<IFlightConnector> mockFlightConnector = new Mock<IFlightConnector>(); | ||
|
||
var eventManager = new SimEventManager( | ||
new LoggerFactory().CreateLogger<SimEventManager>(), | ||
mockFlightConnector.Object | ||
); | ||
|
||
var registration = eventManager.RegisterEvent(KnownEvents.ADF_STBY_SET.ToString()); | ||
Assert.IsNotNull(registration); | ||
|
||
var adfHandler = new AdfHandler( | ||
mockFlightConnector.Object, | ||
eventManager, | ||
eventManager, | ||
Core.TOGGLE_VALUE.ADF_ACTIVE_FREQUENCY__1, | ||
Core.TOGGLE_VALUE.ADF_STANDBY_FREQUENCY__1, | ||
null, | ||
null, | ||
KnownEvents.ADF1_RADIO_SWAP, | ||
KnownEvents.ADF_STBY_SET | ||
); | ||
|
||
await adfHandler.TriggerAsync("120", false); | ||
|
||
mockFlightConnector.Verify(connector => connector.Trigger(registration.Value.eventEnum, 18874368)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
global using Microsoft.Extensions.Logging; | ||
global using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
global using Moq; | ||
global using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters