using System; using UnitTestSharp; namespace Annulus.UnitTests { public class PointyHexDirectionExtensionsTests : TestFixture { public class OppositeTests : TestFixture { public void EastIsWest() { CheckEqual(PointyHexDirection.West, PointyHexDirection.East.Opposite()); } public void SouthEastIsNorthWest() { CheckEqual(PointyHexDirection.NorthWest, PointyHexDirection.SouthEast.Opposite()); } public void SouthWestIsNorthEast() { CheckEqual(PointyHexDirection.NorthEast, PointyHexDirection.SouthWest.Opposite()); } public void IsItsOwnInverse() { for (var direction = PointyHexDirection.East; direction <= PointyHexDirection.NorthEast; ++direction) { CheckEqual(direction, direction.Opposite().Opposite()); } } public void NotAHexDirection_Throws() { CheckThrow(typeof(ArgumentOutOfRangeException)); ((PointyHexDirection)6).Opposite(); } } public class RotatedClockwiseTests : TestFixture { public void OneSixthTurnFromEastIsSouthEast() { CheckEqual(PointyHexDirection.SouthEast, PointyHexDirection.East.RotatedClockwise(1)); } public void WrapsPastNorthEastBackToEast() { CheckEqual(PointyHexDirection.East, PointyHexDirection.NorthEast.RotatedClockwise(1)); } public void NegativeTurnsGoCounterclockwise() { CheckEqual(PointyHexDirection.NorthEast, PointyHexDirection.East.RotatedClockwise(-1)); } public void NotAHexDirection_Throws() { CheckThrow(typeof(ArgumentOutOfRangeException)); ((PointyHexDirection)(-1)).RotatedClockwise(1); } } } }