Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaTest/EndpointParseTests.cs
T
2024-10-22 17:29:04 +03:00

68 lines
2.0 KiB
C#

#nullable enable
extern alias Client;
using System.Net;
using Barotrauma;
using Xunit;
using Barotrauma.Networking;
using FluentAssertions;
using Endpoint = Client::Barotrauma.Networking.Endpoint;
using LidgrenEndpoint = Client::Barotrauma.Networking.LidgrenEndpoint;
using SteamP2PEndpoint = Client::Barotrauma.Networking.SteamP2PEndpoint;
namespace TestProject;
public class EndpointParseTests
{
[Fact]
public void TestLidgrenEndpoint()
{
Endpoint.Parse("127.0.0.1:27015")
.Should()
.BeEquivalentTo(
Option<Endpoint>.Some(new LidgrenEndpoint(IPAddress.Loopback, 27015)),
options => options.RespectingRuntimeTypes());
}
[Fact]
public void TestLidgrenEndpointHostName()
{
Endpoint.Parse("localhost:27015")
.Should()
.BeEquivalentTo(
Option<Endpoint>.Some(new LidgrenEndpoint(IPAddress.Loopback, 27015)),
options => options.RespectingRuntimeTypes());
}
[Fact]
public void TestLidgrenAddress()
{
Address.Parse("127.0.0.1")
.Should()
.BeEquivalentTo(
Option<Address>.Some(new LidgrenAddress(IPAddress.Loopback)),
options => options.RespectingRuntimeTypes());
}
[Fact]
public void TestSteamP2PEndpoint()
{
Endpoint.Parse("STEAM_1:1:508792388")
.Should()
.BeEquivalentTo(
Option<Endpoint>.Some(new SteamP2PEndpoint(new SteamId(76561198977850505))),
options => options.RespectingRuntimeTypes());
}
[Fact]
public void TestSteamP2PAddress()
{
Address.Parse("STEAM_1:1:508792388")
.Should()
.BeEquivalentTo(
Option<Address>.Some(new SteamP2PAddress(new SteamId(76561198977850505))),
options => options.RespectingRuntimeTypes());
new SteamId(76561198977850505).StringRepresentation.Should().BeEquivalentTo("STEAM_1:1:508792388");
}
}