public void TestConsolidation() { var vectorA = new HexVector { PrimaryComponent = new HexVectorComponent(HexAxis.C, 5), SecondaryComponent = new HexVectorComponent(HexAxis.E, 9) }; _utilityLibrary.ConsolidateVector(vectorA); TestChecksUtility.CheckComponent(vectorA.PrimaryComponent, HexAxis.D, 5); TestChecksUtility.CheckComponent(vectorA.SecondaryComponent, HexAxis.E, 4); var vectorB = new RawHexVector(); vectorB.AddComponent(HexAxis.A, 1); vectorB.AddComponent(HexAxis.B, 4); vectorB.AddComponent(HexAxis.C, 3); vectorB.AddComponent(HexAxis.E, 7); vectorB.AddComponent(HexAxis.Up, 2); vectorB.AddComponent(HexAxis.Up, 3); vectorB.AddComponent(HexAxis.Down, 5); var resultB = _utilityLibrary.ConsolidateAndCopyVector(vectorB); TestChecksUtility.CheckComponent(resultB.PrimaryComponent, HexAxis.D, 2); resultB.SecondaryComponent.Should().Be(HexVectorComponent.Zero); resultB.VerticalComponent.Should().Be(HexVectorComponent.Zero); }
public void TestVectorCloning() { var vectorA = new RawHexVector(); vectorA.AddComponent(HexAxis.B, 5); vectorA.AddComponent(HexAxis.F, 2); var hexVector = _utilityLibrary.CloneHexVector <HexVector>(vectorA); TestChecksUtility.CheckComponent(hexVector.PrimaryComponent, HexAxis.B, 5); TestChecksUtility.CheckComponent(hexVector.SecondaryComponent, HexAxis.F, 2); // Cloning does not consolidate vectors. It copies them as they are, so we can't test grid // coordinates copy on vector A. var vectorB = new RawHexVector(); vectorB.AddComponent(HexAxis.C, 5); vectorB.AddComponent(HexAxis.A, 2); var gridCoordinate = _utilityLibrary.CloneHexVector <HexGridCoordinate>(vectorB); gridCoordinate.CfCoordinate.Should().Be(5); gridCoordinate.DaCoordinate.Should().Be(1); }