public void throw_if_landing_area_boundaries_are_bigger_than_limits(int x, int width, int y, int height) { var landingArea = new LandingArea(x, width, y, height); Action action = () => new Platform(landingArea, PlatformWidth, PlatformHeight); action.Should().Throw <ArgumentException>(); }
public void Create_LandingArea_With_LandPlatform_Out_Throw_ArgumentException() { Assert.Throws <ArgumentException>(() => { var landingArea = new LandingArea(100, 100, new Coordinate(1, 3), 100, 100); }); }
public void Create_LandingArea_With_0_Size() { Assert.Throws <ArgumentException>(() => { var landingArea = new LandingArea(0, 0, new Coordinate(1, 3), 100, 100); }); }
public void SetupLandingArea(LandingArea landingArea) { if (_landingArea == null) { _landingArea = landingArea; } }
protected override void Given() { const int areaDimensionX = 100; const int areaDimensionY = 100; const int platformDimensionX = 50; const int platformDimensionY = 50; _positionX = 20; _positionY = 40; var approachCheckResultMapper = new ApproachCheckResultMapper(); var strategy = new ZartisExerciseStrategy(); var platformDimension = new Dimension(platformDimensionX, platformDimensionY); var platform = new LandingPlatform(platformDimension, strategy); var areaDimension = new Dimension(areaDimensionX, areaDimensionY); var area = new LandingArea(areaDimension, platform, approachCheckResultMapper); var rocket = new Rocket(area); rocket.CheckApproach(_positionX, _positionY); _sut = new Rocket(area); _expectedResult = "ok for landing"; _farPositionX = _positionX + 2; }
protected override void Given() { const int areaDimensionX = 100; const int areaDimensionY = 100; const int platformDimensionX = 50; const int platformDimensionY = 50; var platformDimension = new Dimension(platformDimensionX, platformDimensionY); var areaDimension = new Dimension(areaDimensionX, areaDimensionY); _rocketId = GuidGenerator.Create(1); _position = Mock.Of <IPosition>(); _platformMock = new Mock <ILandingPlatform>(); _platformMock .Setup(m => m.GetDimension()) .Returns(platformDimension); _platformMock .Setup(m => m.CheckApproach(_rocketId, _position)) .Returns(ApproachCheckResult); var platform = _platformMock.Object; _expectedResult = "ok"; _approachCheckResultMapperMock = new Mock <IApproachCheckResultMapper>(); _approachCheckResultMapperMock .Setup(m => m.Map(ApproachCheckResult)) .Returns(_expectedResult); var approachCheckResultMapper = _approachCheckResultMapperMock.Object; _sut = new LandingArea(areaDimension, platform, approachCheckResultMapper); }
protected override void Given() { const int x = 5; const int y = 5; var positionOne = new PositionBuilder() .WithX(x) .WithY(y) .Build(); _positionTwo = new PositionBuilder() .WithX(x + 2) .WithY(y + 2) .Build(); var landingPlatform = new LandingPlatformMockBuilder() .WithIsPositionInsideOfPlatformMocked(IsPositionInsideOfThePlatform) .WithIsAllowedPositionMocked(IsAllowedPosition) .Build(); _sut = new LandingAreaBuilder() .WithLandingPlatform(landingPlatform) .Build(); _sut.CheckPosition(positionOne); _expectedResult = LandingAnswer; _expectedPositions = StoredPositions; }
public void Setup() { var landingArea = new LandingArea(5, 10, 5, 10); platform = new Platform(landingArea, PlatformWidth, PlatformHeight); rocketId = Guid.NewGuid().ToString(); otherRocketId = Guid.NewGuid().ToString(); }
public void AskForPosition_Return_OkForLanding() { var landingArea = new LandingArea(100, 100, new Coordinate(5, 5), 10, 10); var result = landingArea.AskForPosition(5, 5); Assert.AreEqual(result, LandingCondition.OkForLanding); }
public void AskForPosition_Return_OutOfPlatform() { var landingArea = new LandingArea(100, 100, new Coordinate(5, 5), 10, 10); var result = landingArea.AskForPosition(15, 16); Assert.AreEqual(result, LandingCondition.OutOfPlatform); }
void TargetLandingArea() { landingArea = FindObjectOfType <LandingArea>(); offsetXZ = CalculateOffsetInXZPlane(); Quaternion rotation = Quaternion.LookRotation(offsetXZ.normalized); transform.rotation = rotation; // Align Heli with Landing Area }
public void TwoRockets_AskForAdjacentPosition_Return_Crash() { var landingArea = new LandingArea(100, 100, new Coordinate(5, 5), 10, 10); var result = landingArea.AskForPosition(7, 7); var result2 = landingArea.AskForPosition(8, 7); Assert.AreEqual(result2, LandingCondition.Clash); }
/// <summary> /// Positions the platform in landing area. /// </summary> /// <param name="landingArea">The landing area.</param> /// <param name="platform">The platform.</param> /// <exception cref="System.NotImplementedException"></exception> public void PositionatePlatformOnLandingArea(LandingArea landingArea, Platform platform) { var landingAreaPositions = registeredPositions.FirstOrDefault(x => x.OwnerId == landingArea.Id); var platformPositions = registeredPositions.FirstOrDefault(x => x.OwnerId == platform.Id); platformPositions.Positions.ForEach(x => { landingAreaPositions.Positions .FirstOrDefault(y => y.PositionX == x.PositionX && y.PositionY == x.PositionY).IsAvailable = false; }); }
public void Helifly() { if (called == true) { landingArea = FindObjectOfType <LandingArea>(); transform.position = Vector3.MoveTowards(transform.position, destination, 30 * Time.deltaTime); } if (transform.position == destination) { called = false; landing = true; } }
protected override void Given() { _position = new PositionBuilder().Build(); var landingPlatform = new LandingPlatformMockBuilder() .WithIsPositionInsideOfPlatformMocked(IsPositionInsideOfThePlatform) .Build(); _sut = new LandingAreaBuilder() .WithLandingPlatform(landingPlatform) .Build(); _expectedResult = LandingAnswer; _expectedPositions = StoredPositions; }
/// <summary> /// Creates the landing zone. /// </summary> public LandingArea CreateLandingZone(string description, double areaX, double areaY) { LandingArea landingArea = new LandingArea() { Id = Guid.NewGuid(), Description = description, AreaX = areaX, AreaY = areaY, fieldsX = Math.Sqrt(areaX), fieldsY = Math.Sqrt(areaY) }; var positionsList = _positionService.GetPositionsList(landingArea.AreaX, landingArea.AreaY); landingArea.AreaPositions = positionsList; landingAreaList.Add(landingArea); _positionService.AddPosition(landingArea.Id, positionsList); return(landingArea); }
/// <summary> /// Gets the board. /// </summary> /// <param name="landingArea">The landing area.</param> /// <returns></returns> public StringBuilder GetDrawLandingArea(LandingArea landingArea) { List <Position> positionList = landingArea.AreaPositions; StringBuilder board = new StringBuilder(); double counter = landingArea.AreaX; for (int i = 1; i <= counter; i++) { var tempList = positionList.Where(p => p.PositionX == i); foreach (var item in tempList) { var stringPositionX = item.PositionX.ToString().Length <= 1 ? $"0{item.PositionX}" : $"{item.PositionX}"; var stringPositionY = item.PositionY.ToString().Length <= 1 ? $"0{item.PositionY}" : $"{item.PositionY}"; board.Append($"|{stringPositionX},{stringPositionY}|"); } board.Append(Environment.NewLine); } return(board); }
/// <summary> /// Creates the landing platform. /// </summary> /// <param name="landingArea">The landing area.</param> /// <param name="descripcion">The descripcion.</param> /// <param name="areaX">The area x.</param> /// <param name="areaY">The area y.</param> /// <param name="minRocketSpace">The minimum rocket space.</param> /// <returns></returns> public Platform CreateLandingPlatform(LandingArea landingArea, string descripcion, double areaX, double areaY, int minRocketSpace, double landingAreaX, double landingAreaY) { Platform platform = new Platform() { Id = Guid.NewGuid(), LandingArea = landingArea, Description = descripcion, AreaX = areaX, AreaY = areaY, MinRocketSpace = minRocketSpace, LandingAreaX = landingAreaX, LandingAreaY = landingAreaY }; _landingAreaService.AddPlatform(landingArea.Id, platform); var positionList = _positionService.GetPositionsList(platform.AreaX, platform.AreaY); _positionService.AddPosition(platform.Id, positionList); _positionService.PositionatePlatformOnLandingArea(landingArea, platform); return(platform); }
protected override void When() { _expectedException = Record.Exception( () => _sut = new LandingArea(_areaDimension, _platform, _approachCheckResultMapper)); }
void CreateLandingArea() { LandingArea area = Instantiate(landingArea); area.transform.position = transform.position; }
public LandingResolver(LandingArea landingArea) { LandingArea = landingArea ?? throw new ArgumentNullException(nameof(landingArea)); LandingOperation = new LandingOperation(LandingArea); }
public LandingArea Build() { var landingArea = new LandingArea(_dimension, _landingPlatform); return(landingArea); }
public void Create_LandingArea() { var landingArea = new LandingArea(100, 100, new Coordinate(1, 1), 5, 5); Assert.AreEqual(landingArea.AreaDimension, 100 * 100); }
public LandingOperation(LandingArea landingArea) { LandingArea = landingArea ?? throw new ArgumentNullException(nameof(landingArea)); MatrixOperation = new MatrixOperation(LandingArea.Matrix); Coordinates = new List <Coordinate>(); }
protected override void When() { _sut = new LandingArea(_areaDimension, _platform, _approachCheckResultMapper); }
protected override void When() { _sut = new LandingArea(_dimension, _landingPlatform); }