baseline: OpenMU upstream b5a0961 (fresh source)
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
// <copyright file="ChatServerPacketTests.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This source code was auto-generated by an XSL transformation.
|
||||
// Do not change this file. Instead, change the XML data which contains
|
||||
// the packet definitions and re-run the transformation (rebuild this project).
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MUnique.OpenMU.Network.Packets.Tests.ChatServer;
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using MUnique.OpenMU.Network.Packets.ChatServer;
|
||||
|
||||
/// <summary>
|
||||
/// Auto-generated tests for packet structures to validate packet definitions.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class PacketStructureTests
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for Authenticate.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void Authenticate_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 16;
|
||||
var actualLength = AuthenticateRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
|
||||
// Validate field 'RoomId' boundary
|
||||
Assert.That(4 + 2, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'RoomId' exceeds packet boundary");
|
||||
|
||||
// Validate field 'Token' boundary
|
||||
Assert.That(6 + 10, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'Token' exceeds packet boundary");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ChatRoomClientJoined.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ChatRoomClientJoined_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 15;
|
||||
var actualLength = ChatRoomClientJoinedRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
|
||||
// Validate field 'ClientIndex' boundary
|
||||
Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'ClientIndex' exceeds packet boundary");
|
||||
|
||||
// Validate field 'Name' boundary
|
||||
Assert.That(5 + 10, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'Name' exceeds packet boundary");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for LeaveChatRoom.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void LeaveChatRoom_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 3;
|
||||
var actualLength = LeaveChatRoomRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ChatRoomClientLeft.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ChatRoomClientLeft_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 15;
|
||||
var actualLength = ChatRoomClientLeftRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
|
||||
// Validate field 'ClientIndex' boundary
|
||||
Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'ClientIndex' exceeds packet boundary");
|
||||
|
||||
// Validate field 'Name' boundary
|
||||
Assert.That(5 + 10, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'Name' exceeds packet boundary");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ChatRoomClients.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ChatRoomClients_PacketSizeValidation()
|
||||
{
|
||||
// Basic packet validation
|
||||
// Validate header type and field boundaries
|
||||
|
||||
// Field 'ClientCount' starts at index 6 with size 1
|
||||
Assert.That(6, Is.GreaterThanOrEqualTo(0),
|
||||
"Field 'ClientCount' has invalid negative index");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ChatMessage.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ChatMessage_PacketSizeValidation()
|
||||
{
|
||||
// Variable-length packet validation
|
||||
// Test GetRequiredSize method with sample data
|
||||
const int testBinaryLength = 10;
|
||||
var calculatedSize = ChatMessageRef.GetRequiredSize(testBinaryLength);
|
||||
var expectedMinSize = testBinaryLength + 5;
|
||||
|
||||
Assert.That(calculatedSize, Is.GreaterThanOrEqualTo(expectedMinSize),
|
||||
"GetRequiredSize calculation incorrect for binary field");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for KeepAlive.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void KeepAlive_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 3;
|
||||
var actualLength = KeepAliveRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,210 @@
|
||||
// <copyright file="ConnectServerPacketTests.cs" company="MUnique">
|
||||
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
|
||||
// </copyright>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This source code was auto-generated by an XSL transformation.
|
||||
// Do not change this file. Instead, change the XML data which contains
|
||||
// the packet definitions and re-run the transformation (rebuild this project).
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace MUnique.OpenMU.Network.Packets.Tests.ConnectServer;
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using NUnit.Framework;
|
||||
using MUnique.OpenMU.Network.Packets.ConnectServer;
|
||||
|
||||
/// <summary>
|
||||
/// Auto-generated tests for packet structures to validate packet definitions.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public class PacketStructureTests
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ConnectionInfoRequest075.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ConnectionInfoRequest075_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 5;
|
||||
var actualLength = ConnectionInfoRequest075Ref.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
|
||||
// Validate field 'ServerId' boundary
|
||||
Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'ServerId' exceeds packet boundary");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ConnectionInfoRequest.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ConnectionInfoRequest_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 6;
|
||||
var actualLength = ConnectionInfoRequestRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
|
||||
// Validate field 'ServerId' boundary
|
||||
Assert.That(4 + 2, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'ServerId' exceeds packet boundary");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ConnectionInfo.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ConnectionInfo_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 22;
|
||||
var actualLength = ConnectionInfoRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
|
||||
// Validate field 'IpAddress' boundary
|
||||
Assert.That(4 + 16, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'IpAddress' exceeds packet boundary");
|
||||
|
||||
// Validate field 'Port' boundary
|
||||
Assert.That(20 + 2, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'Port' exceeds packet boundary");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ServerListRequest.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ServerListRequest_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 4;
|
||||
var actualLength = ServerListRequestRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ServerListResponse.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ServerListResponse_PacketSizeValidation()
|
||||
{
|
||||
// Basic packet validation
|
||||
// Validate header type and field boundaries
|
||||
|
||||
// Field 'ServerCount' starts at index 5 with size 2
|
||||
Assert.That(5, Is.GreaterThanOrEqualTo(0),
|
||||
"Field 'ServerCount' has invalid negative index");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ServerListRequestOld.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ServerListRequestOld_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 4;
|
||||
var actualLength = ServerListRequestOldRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ServerListResponseOld.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ServerListResponseOld_PacketSizeValidation()
|
||||
{
|
||||
// Basic packet validation
|
||||
// Validate header type and field boundaries
|
||||
|
||||
// Field 'ServerCount' starts at index 5 with size 1
|
||||
Assert.That(5, Is.GreaterThanOrEqualTo(0),
|
||||
"Field 'ServerCount' has invalid negative index");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for Hello.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void Hello_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 4;
|
||||
var actualLength = HelloRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for PatchCheckRequest.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PatchCheckRequest_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 6;
|
||||
var actualLength = PatchCheckRequestRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
|
||||
// Validate field 'MajorVersion' boundary
|
||||
Assert.That(3 + 1, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'MajorVersion' exceeds packet boundary");
|
||||
|
||||
// Validate field 'MinorVersion' boundary
|
||||
Assert.That(4 + 1, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'MinorVersion' exceeds packet boundary");
|
||||
|
||||
// Validate field 'PatchVersion' boundary
|
||||
Assert.That(5 + 1, Is.LessThanOrEqualTo(expectedLength),
|
||||
"Field 'PatchVersion' exceeds packet boundary");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for PatchVersionOkay.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PatchVersionOkay_PacketSizeValidation()
|
||||
{
|
||||
// Fixed-length packet validation
|
||||
const int expectedLength = 4;
|
||||
var actualLength = PatchVersionOkayRef.Length;
|
||||
|
||||
Assert.That(actualLength, Is.EqualTo(expectedLength),
|
||||
"Packet length mismatch: declared length does not match calculated size");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the packet size calculation for ClientNeedsPatch.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ClientNeedsPatch_PacketSizeValidation()
|
||||
{
|
||||
// Variable-length packet validation
|
||||
// Test GetRequiredSize method with sample data
|
||||
const string testString = "TestData";
|
||||
var calculatedSize = ClientNeedsPatchRef.GetRequiredSize(testString);
|
||||
var expectedMinSize = Encoding.UTF8.GetByteCount(testString) + 1 + 6;
|
||||
|
||||
Assert.That(calculatedSize, Is.GreaterThanOrEqualTo(expectedMinSize),
|
||||
"GetRequiredSize calculation incorrect for string field");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<WarningsAsErrors>nullable;CS4014;VSTHRD110;VSTHRD100</WarningsAsErrors>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>bin\Debug\MUnique.OpenMU.Network.Packets.Tests.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>bin\Release\MUnique.OpenMU.Network.Packets.Tests.xml</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\..\src\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
|
||||
<Compile Include="..\..\src\SharedGlobalUsings.cs" Link="SharedGlobalUsings.cs" />
|
||||
<Compile Include="..\SharedTestUsings.cs" Link="SharedTestUsings.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include="..\..\src\stylecop.json" Link="stylecop.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\..\src\.editorconfig" Link=".editorconfig" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" />
|
||||
<PackageReference Include="NUnit" />
|
||||
<PackageReference Include="NUnit3TestAdapter" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\Network\Packets\MUnique.OpenMU.Network.Packets.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<Target Name="PreBuild" BeforeTargets="PreBuildEvent" Condition="'$(ci)'!='true'">
|
||||
<!-- Generate test files from XML packet definitions -->
|
||||
<XslTransformation OutputPaths="ClientToServerPacketTests.cs" XmlInputPaths="..\..\src\Network\Packets\ClientToServer\ClientToServerPackets.xml" XslInputPath="..\..\src\Network\Packets\GenerateTests.xslt" Parameters="<Parameter Name='resultFileName' Value='ClientToServerPacketTests.cs'/><Parameter Name='subNamespace' Value='ClientToServer'/>" />
|
||||
<XslTransformation OutputPaths="ServerToClientPacketTests.cs" XmlInputPaths="..\..\src\Network\Packets\ServerToClient\ServerToClientPackets.xml" XslInputPath="..\..\src\Network\Packets\GenerateTests.xslt" Parameters="<Parameter Name='resultFileName' Value='ServerToClientPacketTests.cs'/><Parameter Name='subNamespace' Value='ServerToClient'/>" />
|
||||
<XslTransformation OutputPaths="ChatServerPacketTests.cs" XmlInputPaths="..\..\src\Network\Packets\ChatServer\ChatServerPackets.xml" XslInputPath="..\..\src\Network\Packets\GenerateTests.xslt" Parameters="<Parameter Name='resultFileName' Value='ChatServerPacketTests.cs'/><Parameter Name='subNamespace' Value='ChatServer'/>" />
|
||||
<XslTransformation OutputPaths="ConnectServerPacketTests.cs" XmlInputPaths="..\..\src\Network\Packets\ConnectServer\ConnectServerPackets.xml" XslInputPath="..\..\src\Network\Packets\GenerateTests.xslt" Parameters="<Parameter Name='resultFileName' Value='ConnectServerPacketTests.cs'/><Parameter Name='subNamespace' Value='ConnectServer'/>" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user