Skip to content

Commit

Permalink
Merge pull request #12 from sfawcett123/code_improve_1
Browse files Browse the repository at this point in the history
Key Vault Pair not reporting
  • Loading branch information
sfawcett123 authored Jan 19, 2023
2 parents 37853c9 + 203ab0b commit ba63780
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
17 changes: 7 additions & 10 deletions SimListener/Connect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Connect
#endregion Private

#region Private Methods
private ErrorCodes pAddRequest(string _sNewSimvarRequest, string _sNewUnitRequest, bool _bIsString)
private ErrorCodes InternalAddRequest(string _sNewSimvarRequest, string _sNewUnitRequest, bool _bIsString)
{

if (!ValidateRequest(_sNewSimvarRequest))
Expand Down Expand Up @@ -98,11 +98,11 @@ private void SimConnect_OnRecvOpen(SimConnect sender, SIMCONNECT_RECV_OPEN data)
throw new ArgumentNullException(nameof(sender));
}

_ = pAddRequest("PLANE LATITUDE", "degrees", false);
_ = pAddRequest("PLANE LONGITUDE", "degrees", false);
_ = pAddRequest("AIRSPEED TRUE", "knots", false);
_ = pAddRequest("PLANE ALTITUDE", "feet", false);
_ = pAddRequest("PLANE HEADING DEGREES TRUE", "degrees", false);
_ = InternalAddRequest("PLANE LATITUDE", "degrees", false);
_ = InternalAddRequest("PLANE LONGITUDE", "degrees", false);
_ = InternalAddRequest("AIRSPEED TRUE", "knots", false);
_ = InternalAddRequest("PLANE ALTITUDE", "feet", false);
_ = InternalAddRequest("PLANE HEADING DEGREES TRUE", "degrees", false);


// Register pending requests
Expand Down Expand Up @@ -243,9 +243,6 @@ public Dictionary<string, string> AircraftData()

foreach (SimListener oSimvarRequest in lSimvarRequests)
{
if (oSimvarRequest.Value is null)
continue;

if (oSimvarRequest.Parameter is not null)
{
if (!ReturnValue.ContainsKey(oSimvarRequest.Parameter))
Expand Down Expand Up @@ -281,7 +278,7 @@ public List<Track> TrackData()
}
public ErrorCodes AddRequest(string _sNewSimvarRequest)
{
return pAddRequest(_sNewSimvarRequest, "", true);
return InternalAddRequest(_sNewSimvarRequest, "", true);
}
public string AddRequests(List<string> Outputs)
{
Expand Down
29 changes: 24 additions & 5 deletions SimListenerTest/ConnectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ConnectTests
[TestMethod()]
public void AddRequestsTest1()
{
Connect cnx = new Connect();
Connect cnx = new();

ErrorCodes answer = cnx.AddRequest("SHOULD FAIL");
Assert.AreEqual(ErrorCodes.INVALID_DATA_REQUEST, answer);
Expand All @@ -24,7 +24,7 @@ public void AddRequestsTest1()
[TestMethod()]
public void AddRequestsTest2()
{
Connect cnx = new Connect();
Connect cnx = new();

foreach (string name in SimVars.Names)
{
Expand All @@ -36,7 +36,7 @@ public void AddRequestsTest2()
[TestMethod()]
public void AddRequestsTest3()
{
Connect cnx = new Connect();
Connect cnx = new();

string answer = cnx.AddRequests(SimVars.Names.ToList<string>());

Expand All @@ -46,13 +46,32 @@ public void AddRequestsTest3()
[TestMethod()]
public void AddRequestsTest4()
{
Connect cnx = new Connect();
Connect cnx = new();

List<string> Test = new List<string>() { "WONT WORK" };
List<string> Test = new() { "WONT WORK" };

string answer = cnx.AddRequests(Test);

Assert.AreEqual("WONT WORK", answer);
}

[TestMethod()]
public void AddRequestsTest5()
{
Connect cnx = new();

KeyValuePair<string, string> Data = new KeyValuePair<string, string>("PLANE ALTITUDE", "");

List<string> Test = new() { Data.Key };

string answer = cnx.AddRequests(Test);

foreach( var req in cnx.AircraftData() )
{
Console.WriteLine( $"OUTPUT -> {req}" );
}

Assert.IsTrue( cnx.AircraftData().Contains( Data ) );
}
}
}

0 comments on commit ba63780

Please sign in to comment.