baseline: OpenMU upstream b5a0961 (fresh source)
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user