Files
LuaCsForBarotraumaEP/Barotrauma/BarotraumaTest/EndpointParseTests.cs
Markus Isberg 9470edead3 Build 1.1.4.0
2023-03-31 18:40:44 +03:00

63 lines
1.8 KiB
C#

#nullable enable
using System.Net;
using Barotrauma;
using Xunit;
using Barotrauma.Networking;
using FluentAssertions;
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");
}
}