using AutoFixture; using FluentAssertions; using Microsoft.VisualStudio.TestTools.UnitTesting; using PathFinding; using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Gameboard.ShogiUI.UnitTests.PathFinding { [TestClass] public class PlanarCollectionShould { private class SimpleElement : IPlanarElement { public static int Seed { get; private set; } public MoveSet MoveSet => null; public bool IsUpsideDown => false; public SimpleElement() { Seed = Seed++; } } private Fixture fixture; [TestInitialize] public void TestInitialize() { fixture = new Fixture(); } [TestMethod] public void Index() { // Arrange var collection = new PlanarCollection(10, 10); var expected1 = new SimpleElement(); var expected2 = new SimpleElement(); // Act collection[0, 0] = expected1; collection[2, 1] = expected2; // Assert collection[0, 0].Should().Be(expected1); collection[2, 1].Should().Be(expected2); } [TestMethod] public void Iterate() { // Arrange var expected = new List(); for (var i = 0; i < 9; i++) expected.Add(new SimpleElement()); var collection = new PlanarCollection(3, 3); for (var x = 0; x < 3; x++) for (var y = 0; y < 3; y++) collection[x, y] = expected[x + y]; // Act var actual = new List(); foreach (var elem in collection) actual.Add(elem); // Assert actual.Should().BeEquivalentTo(expected); } [TestMethod] public void Yep() { var collection = new PlanarCollection(3, 3); collection[0, 0] = new SimpleElement(); collection[1, 0] = new SimpleElement(); collection[0, 1] = new SimpleElement(); // Act var array2d = new SimpleElement[3, 3]; for (var x = 0; x < 3; x++) for (var y = 0; y < 3; y++) { array2d[x, y] = collection[x, y]; } Console.WriteLine("hey"); } } }