public void TwoCrosses() { TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(2, 2); TrackLayout.AddTrack(3, 2); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(1, 4); TrackLayout.AddTrack(2, 4); TrackLayout.AddTrack(3, 4); TrackLayout.AddTrack(2, 5); TrackLayout.AddTrack(2, 3); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 2).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 2).Direction); Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 4).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 4).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 4).Direction); Assert.True(TrackLayout.GetTrackAt(2, 3).Happy); }
public void Three_Verticals() { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(1, 3); TrackLayout.AddTrack(1, 4); TrackLayout.AddTrack(1, 5); TrackLayout.AddTrack(2, 2); TrackLayout.AddTrack(2, 3); TrackLayout.AddTrack(2, 4); TrackLayout.AddTrack(3, 3); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 3).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 4).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 5).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 4).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 3).Direction); }
public void Horizontal() { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(2, 1); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction); }
public void Vertical_TrainMovement(float startAngle, int startColumn, int startRow, int endColumn, int endRow) { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(1, 3); AssertTrainMovement(startAngle, startColumn, startRow, endColumn, endRow); }
public void Horizontal_TrainMovement(float startAngle, int startColumn, int startRow, int endColumn, int endRow) { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(3, 1); AssertTrainMovement(startAngle, startColumn, startRow, endColumn, endRow); }
public void Vertical() { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(1, 2); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction); }
public void LeftDown_TrainMovement(float startAngle, int startColumn, int startRow, int endColumn, int endRow) { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(2, 2); AssertTrainMovement(startAngle, startColumn, startRow, endColumn, endRow); }
public void LeftUp() { TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(2, 2); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(2, 2).Direction); }
public void RightDown() { TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(1, 2); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction); }
public void SidewaysHairpin() { TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(2, 2); TrackLayout.AddTrack(3, 2); TrackLayout.AddTrack(3, 1); TrackLayout.AddTrack(2, 1); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 2).Direction); Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(3, 2).Direction); Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(3, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction); }
public void VerticalHairpin() { TrackLayout.AddTrack(1, 3); TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(2, 2); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 3).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction); }
public void CrossMiddleLast() { TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(3, 2); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(2, 3); TrackLayout.AddTrack(2, 2); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 2).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 2).Direction); }
public void Happiness() { TrackLayout.AddTrack(1, 1); Assert.False(TrackLayout.GetTrackAt(1, 1).Happy); TrackLayout.AddTrack(1, 2); Assert.False(TrackLayout.GetTrackAt(1, 1).Happy); Assert.False(TrackLayout.GetTrackAt(1, 2).Happy); TrackLayout.AddTrack(1, 3); Assert.False(TrackLayout.GetTrackAt(1, 1).Happy); Assert.True(TrackLayout.GetTrackAt(1, 2).Happy); Assert.False(TrackLayout.GetTrackAt(1, 3).Happy); }
public void MovementTest_FullTrackLoop_3x3Square(float initialTrainAngle) { var trackLayout = new TrackLayout(); var board = new GameBoard(trackLayout, null, null); trackLayout.AddTrack(1, 1); trackLayout.AddTrack(2, 1); trackLayout.AddTrack(3, 1); trackLayout.AddTrack(3, 2); trackLayout.AddTrack(3, 3); trackLayout.AddTrack(2, 3); trackLayout.AddTrack(1, 3); trackLayout.AddTrack(1, 2); board.AddTrain(2, 1); var train = (Train)board.GetMovables().Single(); float distance = (float)(4 * StraightTrackDistance + 4 * CornerTrackDistance); // Train speed & angle train.ForceSpeed(distance / _movementSteps / Train.SpeedScaleModifier); train.SetAngle(initialTrainAngle); Assert.Equal(2, train.Column); Assert.Equal(1, train.Row); Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision); Assert.Equal(0.5f, train.RelativeTop, MovementPrecision); Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision); // Move it! for (int i = 0; i < _movementSteps; i++) { board.GameLoopStep(); } Assert.Equal(2, train.Column); Assert.Equal(1, train.Row); Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision); Assert.Equal(0.5f, train.RelativeTop, MovementPrecision); Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision); }
public void LeftAngleWithCircleOnTop() { TrackLayout.AddTrack(1, 3); TrackLayout.AddTrack(2, 3); TrackLayout.AddTrack(2, 4); TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(2, 2); TrackLayout.AddTrack(1, 2); Assert.Equal(TrackDirection.RightUp, TrackLayout.GetTrackAt(1, 3).Direction); Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 4).Direction); Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(2, 2).Direction); Assert.Equal(TrackDirection.RightUpDown, TrackLayout.GetTrackAt(1, 2).Direction); }
public void LeftRightDown_DrawOver() { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(3, 1); TrackLayout.AddTrack(2, 2); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 2).Direction); TrackLayout.AddTrack(2, 1); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.RightDown_LeftDown, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 1).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction); }
public void LeftRightUp_DrawOver() { TrackLayout.AddTrack(1, 3); TrackLayout.AddTrack(2, 3); TrackLayout.AddTrack(3, 3); TrackLayout.AddTrack(2, 2); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 3).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 3).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 2).Direction); TrackLayout.AddTrack(2, 3); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(1, 3).Direction); Assert.Equal(TrackDirection.LeftRightUp, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 3).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction); }
public void Two_Verticals() { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(1, 3); TrackLayout.AddTrack(1, 4); TrackLayout.AddTrack(2, 2); TrackLayout.AddTrack(2, 3); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 3).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 4).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 2).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction); }
public void Trident() { TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(2, 2); TrackLayout.AddTrack(3, 2); TrackLayout.AddTrack(3, 1); TrackLayout.AddTrack(2, 3); TrackLayout.AddTrack(2, 2); TrackLayout.AddTrack(2, 1); Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.RightUp, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.Cross, TrackLayout.GetTrackAt(2, 2).Direction); Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(3, 2).Direction); Assert.Equal(TrackDirection.LeftDown, TrackLayout.GetTrackAt(3, 1).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.LeftRightDown, TrackLayout.GetTrackAt(2, 1).Direction); }
public void FishHook() { TrackLayout.AddTrack(5, 2); TrackLayout.AddTrack(4, 2); TrackLayout.AddTrack(3, 2); TrackLayout.AddTrack(3, 3); TrackLayout.AddTrack(2, 3); TrackLayout.AddTrack(1, 3); TrackLayout.AddTrack(1, 2); TrackLayout.AddTrack(1, 1); TrackLayout.AddTrack(2, 1); TrackLayout.AddTrack(3, 1); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(5, 2).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(4, 2).Direction); Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(3, 2).Direction); Assert.Equal(TrackDirection.LeftUp, TrackLayout.GetTrackAt(3, 3).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 3).Direction); Assert.Equal(TrackDirection.RightUp, TrackLayout.GetTrackAt(1, 3).Direction); Assert.Equal(TrackDirection.Vertical, TrackLayout.GetTrackAt(1, 2).Direction); Assert.Equal(TrackDirection.RightDown, TrackLayout.GetTrackAt(1, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(2, 1).Direction); Assert.Equal(TrackDirection.Horizontal, TrackLayout.GetTrackAt(3, 1).Direction); }
public void MovementTest_FullTrackLoop_FourLoopCorners(float initialTrainAngle) { var trackLayout = new TrackLayout(); var board = new GameBoard(trackLayout, null, null); trackLayout.AddTrack(3, 2); trackLayout.AddTrack(4, 2); trackLayout.AddTrack(5, 2); trackLayout.AddTrack(5, 1); trackLayout.AddTrack(4, 1); trackLayout.AddTrack(4, 3); trackLayout.AddTrack(4, 4); trackLayout.AddTrack(4, 5); trackLayout.AddTrack(5, 5); trackLayout.AddTrack(5, 4); trackLayout.AddTrack(3, 4); trackLayout.AddTrack(2, 4); trackLayout.AddTrack(1, 4); trackLayout.AddTrack(1, 5); trackLayout.AddTrack(2, 5); trackLayout.AddTrack(2, 3); // Skip until end! trackLayout.AddTrack(2, 1); trackLayout.AddTrack(1, 1); trackLayout.AddTrack(1, 2); // Finish it off trackLayout.AddTrack(2, 2); board.AddTrain(3, 2); var train = (Train)board.GetMovables().Single(); float distance = (float)(12 * StraightTrackDistance + 12 * CornerTrackDistance); train.Angle = initialTrainAngle; train.ForceSpeed(distance / _movementSteps / Train.SpeedScaleModifier); Assert.Equal(3, train.Column); Assert.Equal(2, train.Row); Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision); Assert.Equal(0.5f, train.RelativeTop, MovementPrecision); Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision); // Move it! for (int i = 0; i < _movementSteps; i++) { board.GameLoopStep(); } Assert.Equal(3, train.Column); Assert.Equal(2, train.Row); Assert.Equal(0.5f, train.RelativeLeft, MovementPrecision); Assert.Equal(0.5f, train.RelativeTop, MovementPrecision); Assert.Equal(initialTrainAngle, train.Angle, MovementPrecision); }