This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/tests/MfGames.Nitride.Tests/Entities/LinkEntitySequenceTests.cs

68 lines
1.8 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Linq;
2022-09-06 05:53:22 +00:00
using MfGames.Gallium;
using MfGames.Nitride.Entities;
using Xunit;
using Xunit.Abstractions;
2022-09-06 05:53:22 +00:00
namespace MfGames.Nitride.Tests.Entities;
public class LinkEntitySequenceTests : NitrideTestBase
{
public LinkEntitySequenceTests(ITestOutputHelper output)
: base(output)
{
}
[Fact]
public void LinkThree()
{
NitrideTestContext context = this.CreateContext();
LinkEntitySequence op = context.Resolve<LinkEntitySequence>();
var input = new List<Entity>
{
new Entity().Add("page1"),
new Entity().Add("page2"),
new Entity().Add("page3"),
};
2022-07-09 04:52:10 +00:00
var results = op.Run(input)
.ToList();
Assert.Equal(3, results.Count);
2022-07-09 04:52:10 +00:00
EntitySequence seq1 = results[0]
.Get<EntitySequence>();
EntitySequence seq2 = results[1]
.Get<EntitySequence>();
EntitySequence seq3 = results[2]
.Get<EntitySequence>();
Assert.True(seq1.IsFirst);
Assert.False(seq1.IsLast);
Assert.False(seq1.HasPrevious);
Assert.True(seq1.HasNext);
Assert.Null(seq1.Previous?.Get<string>());
Assert.Equal("page2", seq1.Next!.Get<string>());
Assert.False(seq2.IsFirst);
Assert.False(seq2.IsLast);
Assert.True(seq2.HasPrevious);
Assert.True(seq2.HasNext);
Assert.Equal("page1", seq2.Previous!.Get<string>());
Assert.Equal("page3", seq2.Next!.Get<string>());
Assert.False(seq3.IsFirst);
Assert.True(seq3.IsLast);
Assert.True(seq3.HasPrevious);
Assert.False(seq3.HasNext);
Assert.Equal("page2", seq3.Previous!.Get<string>());
Assert.Null(seq3.Next?.Get<string>());
}
}