mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
Add tests
This commit is contained in:
parent
737da7d40c
commit
a1f5693180
1 changed files with 37 additions and 0 deletions
37
v2rayN/ServiceLib.Tests/Fmt/InnerFmtTests.cs
Normal file
37
v2rayN/ServiceLib.Tests/Fmt/InnerFmtTests.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
using AwesomeAssertions;
|
||||||
|
using ServiceLib.Enums;
|
||||||
|
using ServiceLib.Handler.Fmt;
|
||||||
|
using ServiceLib.Tests.CoreConfig;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace ServiceLib.Tests.Fmt;
|
||||||
|
|
||||||
|
public class InnerFmtTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void ToUriAndResolve_ShouldRoundTripPolicyGroupReferences()
|
||||||
|
{
|
||||||
|
var childA = CoreConfigTestFactory.CreateSocksNode(ECoreType.Xray, "child-a", "child-a");
|
||||||
|
var childB = CoreConfigTestFactory.CreateVmessNode(ECoreType.Xray, "child-b", "child-b");
|
||||||
|
var group = CoreConfigTestFactory.CreatePolicyGroupNode(ECoreType.Xray, "group-1", "group-1",
|
||||||
|
[childA.IndexId, childB.IndexId]);
|
||||||
|
group.SetProtocolExtra(group.GetProtocolExtra() with { SubChildItems = "original-sub" });
|
||||||
|
|
||||||
|
var uri = InnerFmt.ToUri([group, childA, childB]);
|
||||||
|
|
||||||
|
uri.Should().NotBeNullOrWhiteSpace();
|
||||||
|
|
||||||
|
var resolved = InnerFmt.Resolve(uri!, "sub-123");
|
||||||
|
|
||||||
|
resolved.Should().NotBeNull();
|
||||||
|
resolved.Should().HaveCount(3);
|
||||||
|
|
||||||
|
var resolvedGroup = resolved!.Single(x => x.Remarks == group.Remarks);
|
||||||
|
var resolvedChildA = resolved.Single(x => x.Remarks == childA.Remarks);
|
||||||
|
var resolvedChildB = resolved.Single(x => x.Remarks == childB.Remarks);
|
||||||
|
|
||||||
|
resolvedGroup.ConfigType.Should().Be(EConfigType.PolicyGroup);
|
||||||
|
resolvedGroup.GetProtocolExtra().SubChildItems.Should().Be("sub-123");
|
||||||
|
resolvedGroup.GetProtocolExtra().ChildItems.Should().Be($"{resolvedChildA.IndexId},{resolvedChildB.IndexId}");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue