Files
Shogi/Gameboard.ShogiUI.UnitTests/PathFinding/PlanarCollectionShould.cs
2021-08-01 17:32:43 -05:00

58 lines
1.5 KiB
C#

using AutoFixture;
using FluentAssertions;
using FluentAssertions.Execution;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
namespace Gameboard.ShogiUI.UnitTests.PathFinding
{
[TestClass]
public class PlanarCollectionShould
{
[TestMethod]
public void Index()
{
// Arrange
var collection = new TestPlanarCollection();
var expected1 = new SimpleElement(1);
var expected2 = new SimpleElement(2);
// 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 planarCollection = new TestPlanarCollection();
planarCollection[0, 0] = new SimpleElement(1);
planarCollection[0, 1] = new SimpleElement(2);
planarCollection[0, 2] = new SimpleElement(3);
planarCollection[1, 0] = new SimpleElement(4);
planarCollection[1, 1] = new SimpleElement(5);
// Act
var actual = new List<SimpleElement>();
foreach (var elem in planarCollection)
actual.Add(elem);
// Assert
using (new AssertionScope())
{
actual[0].Number.Should().Be(1);
actual[1].Number.Should().Be(2);
actual[2].Number.Should().Be(3);
actual[3].Number.Should().Be(4);
actual[4].Number.Should().Be(5);
}
}
}
}