initial commit
This commit is contained in:
52
ENIGProtocol.Tests/EEProtocolTests.cs
Normal file
52
ENIGProtocol.Tests/EEProtocolTests.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Xunit;
|
||||
using ENIG;
|
||||
|
||||
namespace ENIGProtocol.Tests
|
||||
{
|
||||
public class EEProtocolTests
|
||||
{
|
||||
[Fact]
|
||||
public void TestCRC16Calculation()
|
||||
{
|
||||
// 테스트 데이터
|
||||
byte[] testData = new byte[] { 0x02,0x00,0xFF };
|
||||
|
||||
// CRC16 계산
|
||||
var protocol = new EEProtocol();
|
||||
ushort crc = protocol.CalculateCRC16(testData);
|
||||
|
||||
// 예상 결과와 비교
|
||||
Assert.Equal(0x1789, crc); // 실제 예상값으로 수정 필요
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPacketCreation()
|
||||
{
|
||||
// 패킷 생성 테스트
|
||||
var protocol = new EEProtocol();
|
||||
byte[] packet = protocol.CreatePacket(0x01, 0x02, new byte[] { 0x03, 0x04 });
|
||||
|
||||
// 패킷 구조 검증
|
||||
Assert.Equal(0x02, packet[0]); // STX
|
||||
Assert.Equal(0x04, packet[1]); // Length
|
||||
Assert.Equal(0x01, packet[2]); // ID
|
||||
Assert.Equal(0x02, packet[3]); // Command
|
||||
Assert.Equal(0x03, packet[4]); // Data[0]
|
||||
Assert.Equal(0x04, packet[5]); // Data[1]
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestPacketParsing()
|
||||
{
|
||||
// 패킷 파싱 테스트
|
||||
var protocol = new EEProtocol();
|
||||
//byte[] testPacket = new byte[] { 0x02, 0x04, 0x01, 0x02, 0x03, 0x04, 0x12, 0x34, 0x03 };
|
||||
byte[] testPacket = new byte[] { 0x02, 0x02, 0x00, 0xFF, 0x89, 0x17, 0x03 };
|
||||
|
||||
|
||||
bool result = protocol.ParsePacket(testPacket);
|
||||
|
||||
Assert.True(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
33
ENIGProtocol.Tests/ENIGProtocol.Tests.csproj
Normal file
33
ENIGProtocol.Tests/ENIGProtocol.Tests.csproj
Normal file
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.4">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\enigprotocol\enigprotocol.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="Xunit" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
10
ENIGProtocol.Tests/UnitTest1.cs
Normal file
10
ENIGProtocol.Tests/UnitTest1.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ENIGProtocol.Tests;
|
||||
|
||||
public class UnitTest1
|
||||
{
|
||||
[Fact]
|
||||
public void Test1()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user