Skip to content

Commit 9c7dddd

Browse files
committed
test: 增加单元测试
1 parent f94ad6f commit 9c7dddd

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/extensions/BootstrapBlazor.Socket/PropertyConverter/DataByteConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public class DataByteConverter : IDataPropertyConverter
1515
/// <param name="data"></param>
1616
public object? Convert(ReadOnlyMemory<byte> data)
1717
{
18-
return data.Length > 0 ? data.Span[0] : 0x0;
18+
return data.Length > 0 ? data.Span[0] : byte.MinValue;
1919
}
2020
}

test/UnitTestTcpSocket/TcpSocketFactoryTest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@ public async Task TryConvertTo_Ok()
670670
Assert.Equal([1, 2, 3, 4, 5], entity.Header);
671671
Assert.Equal([3, 4], entity.Body);
672672

673+
// byte
674+
Assert.Equal(0x1, entity.Value15);
675+
673676
// string
674677
Assert.Equal("1", entity.Value1);
675678

@@ -1415,6 +1418,9 @@ class MockEntity
14151418
public string? Value14 { get; set; }
14161419

14171420
public string? Value13 { get; set; }
1421+
1422+
[DataPropertyConverter(Type = typeof(byte), Offset = 0, Length = 1)]
1423+
public byte Value15 { get; set; }
14181424
}
14191425

14201426
class MockSocketDataConverter : DataConverter<MockEntity>

0 commit comments

Comments
 (0)