Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-dmxc committed Mar 17, 2024
1 parent 8d536ce commit 5b560a5
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 31 deletions.
4 changes: 3 additions & 1 deletion RDMSharp/RDM/Device/AbstractGeneratedRDMDevice.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using RDMSharp.ParameterWrapper;
using Microsoft.Extensions.Logging;
using RDMSharp.ParameterWrapper;
using System;
using System.Collections.Concurrent;
using System.Linq;
Expand Down Expand Up @@ -312,6 +313,7 @@ protected override bool OnUpdateParametrerValueCache(ERDM_Parameter parameter, o
}
catch (Exception e)
{
Logger?.LogError(e, string.Empty);
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion RDMSharp/RDM/Device/AbstractRDMDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ when setParameterWrapperRequestContravarianceFloat.SetRequestParameterDataToObje
}
catch (Exception e)
{

Logger?.LogError(e, string.Empty);
}
FAIL:

Expand Down
19 changes: 0 additions & 19 deletions RDMSharp/RDM/RDMMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,7 @@ public object Value
}
catch (Exception ex)
{
#if DEBUG
Logger?.LogError(string.Empty, ex);
#endif
return null;
}
}
Expand Down Expand Up @@ -457,23 +455,6 @@ public override int GetHashCode()
result = (result * 31) ^ b;
return result;
}
//int hashCode = 1518318531;
//hashCode = hashCode * -1521134295 + MessageLength.GetHashCode();
//hashCode = hashCode * -1521134295 + SourceUID.GetHashCode();
//hashCode = hashCode * -1521134295 + DestUID.GetHashCode();
//hashCode = hashCode * -1521134295 + TransactionCounter.GetHashCode();
//hashCode = hashCode * -1521134295 + PortID_or_Responsetype.GetHashCode();
//hashCode = hashCode * -1521134295 + MessageCounter.GetHashCode();
//hashCode = hashCode * -1521134295 + SubDevice.GetHashCode();
//hashCode = hashCode * -1521134295 + Command.GetHashCode();
//hashCode = hashCode * -1521134295 + Parameter.GetHashCode();
//hashCode = hashCode * -1521134295 + EqualityComparer<ERDM_NackReason[]>.Default.GetHashCode(NackReason);
//hashCode = hashCode * -1521134295 + PDL.GetHashCode();
//hashCode = hashCode * -1521134295 + EqualityComparer<byte[]>.Default.GetHashCode(ParameterData);
//hashCode = hashCode * -1521134295 + Checksum.GetHashCode();
//hashCode = hashCode * -1521134295 + IsAck.GetHashCode();
//hashCode = hashCode * -1521134295 + EqualityComparer<object>.Default.GetHashCode(Value);
//return hashCode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ public static async Task RDMMessageSend(RDMMessage rdmMessage)
var combined = new byte[Math.Max(newData.Length, oldData?.Length ?? 0)];
for (int i = 0; i < combined.Length; i++)
{
byte n = (byte)(newData.Length > i ? newData[i] : 0);
byte o = (byte)((oldData?.Length ?? 0) > i ? oldData[i] : 0);
byte n = (byte)(newData.Length > i ? newData[i] : 0);
#pragma warning disable CS8602 // Dereferenzierung eines möglichen Nullverweises.
byte o = (byte)((oldData?.Length ?? 0) > i ? oldData[i] : 0);
#pragma warning restore CS8602 // Dereferenzierung eines möglichen Nullverweises.
combined[i] = (byte)(n | o);
}
data = combined;
Expand Down
17 changes: 11 additions & 6 deletions RDMSharpTests/Devices/TestRDMDiscovery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace RDMSharpTest.RDM.Devices
public class TestRDMDiscovery
{
private List<MockGeneratedDevice1> mockDevices = new List<MockGeneratedDevice1>();
private MockDiscoveryTool mockDiscoveryTool;
private List<RDMUID> expected;
private MockDiscoveryTool? mockDiscoveryTool;
private List<RDMUID>? expected;
[SetUp]
public void Setup()
{
Expand Down Expand Up @@ -39,6 +39,11 @@ public void Report(RDMDiscoveryStatus value)

private async Task AssertDiscovery(bool full = true)
{
if (mockDiscoveryTool == null)
Assert.Fail($"{nameof(mockDiscoveryTool)} is null");
if (expected == null)
Assert.Fail($"{nameof(expected)} is null");

foreach (var m in mockDevices)
m.ImitateRealConditions = true;
var progress = new DiscoveryProgress();
Expand All @@ -51,10 +56,10 @@ private async Task AssertDiscovery(bool full = true)
Console.WriteLine(e.ToString());
};
Assert.That(progress.status.RangeDoneInPercent, Is.EqualTo(0));
var res = await mockDiscoveryTool.PerformDiscovery(progress, full);
Assert.That(res, Is.EquivalentTo(expected));
Assert.That(progress.status.MessageCount, Is.AtLeast(expected.Count * 3));
Assert.That(progress.status.FoundDevices, Is.EqualTo(expected.Count));
var res = await mockDiscoveryTool!.PerformDiscovery(progress, full);
Assert.That(res, Is.EquivalentTo(expected!));
Assert.That(progress.status.MessageCount, Is.AtLeast(expected!.Count * 3));
Assert.That(progress.status.FoundDevices, Is.EqualTo(expected!.Count));
Assert.That(progress.status.RangeLeftToSearch, Is.EqualTo(0));
Assert.That(progress.status.RangeDoneInPercent, Is.EqualTo(1));
}
Expand Down
2 changes: 1 addition & 1 deletion RDMSharpTests/RDM/ParameterWrappersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ object getValue(Type type)
#endregion

Assert.Warn(type.Name);
return null;
throw new Exception();
}
}

Expand Down
1 change: 1 addition & 0 deletions RDMSharpTests/RDM/UpdateManufacturerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void Setup()
[Test]
public async Task UpdateManufacturerListMethode()
{
return; //Disabled for now
using (var client = new HttpClient())

Check warning on line 16 in RDMSharpTests/RDM/UpdateManufacturerList.cs

View workflow job for this annotation

GitHub Actions / build

Unreachable code detected
{
var website = await client.GetStringAsync("https://tsp.esta.org/tsp/working_groups/CP/mfctrIDs.php");
Expand Down
1 change: 0 additions & 1 deletion RDMSharpTests/TestManyObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public void TestSubDevice()
subdevices.Add(new SubDevice(i));
subdevices.Add(SubDevice.Broadcast);

ushort index = 0;
SubDevice? prev = null;
HashSet<SubDevice> hashSet= new HashSet<SubDevice>();
foreach (SubDevice sd in subdevices)
Expand Down

0 comments on commit 5b560a5

Please sign in to comment.