fix: remote update failed

This commit is contained in:
2025-05-04 21:56:19 +08:00
parent c6b819f24f
commit 55e363d505
3 changed files with 153 additions and 53 deletions

View File

@@ -1,3 +1,4 @@
using System.Buffers.Binary;
using Common;
namespace server.test;
@@ -45,4 +46,16 @@ public class CommonTest
Assert.Equal(Number.ToBit(0xAA, 3).Value, true);
Assert.Equal(Number.ToBit(0xAA, 2).Value, false);
}
[Fact]
public void ReverseBits()
{
Assert.Equal(BinaryPrimitives.ReverseEndianness((byte)0xA0), (byte)0x50);
var bytesSrc = new byte[] { 0xAB, 0x00, 0x00, 0x01 };
var bytes = new byte[4];
for (int i = 0; i < 4; i++)
bytes[i] = BinaryPrimitives.ReverseEndianness(bytesSrc[i]);
Assert.Equal(bytesSrc, new byte[] { 0xD5, 0x00, 0x00, 0x80 });
}
}

View File

@@ -92,7 +92,7 @@ public class UDPServerTest
Assert.True(ret.HasValue);
var data = ret.Value;
Assert.Equal(address, data.Address);
Assert.Equal(number, Number.BytesToNumber(data.Data));
Assert.Equal(number, Number.BytesToUInt32(data.Data).Value);
}
}
@@ -112,7 +112,7 @@ public class UDPServerTest
Assert.True(ret.IsSuccessful);
var data = ret.Value;
Assert.True(data.IsSuccessful);
Assert.Equal(number, Number.BytesToNumber(data.ToBytes()));
Assert.Equal(number, Number.BytesToUInt32(data.ToBytes()).Value);
}
}
@@ -132,7 +132,7 @@ public class UDPServerTest
Assert.True(ret.IsSuccessful);
var data = ret.Value;
Assert.True(data.IsSuccessful);
Assert.Equal(number, Number.BytesToNumber(data.ToBytes()));
Assert.Equal(number, Number.BytesToUInt32(data.ToBytes()).Value);
}
}
}