using System.Linq; using System.Utility; using Chernobyl.Extensions; using Chernobyl.Mathematics.Geometry; using NUnit.Framework; namespace Chernobyl.Generation.Test { [TestFixture, Description("Tests verifying that features can be implemented using Chernobyl.Generation.")] public class FeatureTests { [Test, Description("Create a conflicted pattern")] public void CreateConflictedPattern() { var row = Func.StaticFactory(0) .AddBeat(3, () => 1) .AddRepeater(9) .Invoke() .ToArray(); row.IsEqualTo(new [] { 0, 0, 1, 0, 0, 1, 0, 0, 1 }, "row"); } [Test, Description("Create a pattern conflicted using another conflicted pattern")] public void CreateMultipleConflictedPatterns() { var beatConflicter = Func.StaticFactory(1).AddBeat(2, () => 2); var row = Func.StaticFactory(0) .AddBeat(3, beatConflicter) .AddRepeater(9) .Invoke() .ToArray(); row.IsEqualTo(new[] { 0, 0, 1, 0, 0, 2, 0, 0, 1 }, "row"); } [Test, Description("Create a square pattern on the bottom left of a background")] public void CreateBottomLeftSquareOnBackground() { var data2D = Func.StaticFactory(1) .To2D() .Replace(Plane.Predicate.Square((0, .8), .3, .3), pos => 2) .To1D(6, 6) .ToArray(); data2D.IsEqualTo(new[] { 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, nameof(data2D)); } [Test, Description("Create a square pattern on the center of a background")] public void CreateCenterSquareOnBackground() { var data2D = Func.StaticFactory(1) .To2D() .Replace(Plane.Predicate.Square((.4, .4), .3, .3), pos => 2) .To1D(6, 6) .ToArray(); data2D.IsEqualTo(new [] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }, nameof(data2D)); } } }