public void Calculate_AngleCorrect_ReturnsRightAngle(int x1, int y1, int x2, int y2, int angleBetween) { var firstTrack = FakeTrackFactory.GetTrack(x1, y1, 0); var secondTrack = FakeTrackFactory.GetTrack(x2, y2, 0); var result = _uutTrackCourseCalculator.Calculate(firstTrack, secondTrack); Assert.That(result, Is.EqualTo(angleBetween).Within(1).Percent); }
public void Calculate_CalculateRightTrackDistance_ReturnIsCorrect(int x1, int y1, int x2, int y2, int expected) { var firstTrack = FakeTrackFactory.GetTrack(x1, y1, 100); var secondTrack = FakeTrackFactory.GetTrack(x2, y2, 100); var result = _uutTrackHorizontalDistanceCalculator.Calculate(firstTrack, secondTrack); Assert.That(result.Equals(expected)); }
public void ConditionBetween_ConditionNotFoundAnyCoordinate_ReturnsFalse(int horizontalRestriction, int xTrack1, int yTrack1, int xTrack2, int yTrack2) { _uutTrackHorizontalDistanceCondition.HorizontalDistance = horizontalRestriction; ITrack track1 = FakeTrackFactory.GetTrack(xTrack1, yTrack1, 1000); ITrack track2 = FakeTrackFactory.GetTrack(xTrack2, yTrack2, 1000); var result = _uutTrackHorizontalDistanceCondition.ConditionBetween(track1, track2); Assert.That(result == false); }
public void ConditionBetween_ConditionNotFound_ReturnsFalse(int altitudeRestriction, int altitudeTrack1, int altitudeTrack2) { _uuTrackAltitudeCondition.AltitudeRestriction = altitudeRestriction; ITrack track1 = FakeTrackFactory.GetTrack(1000, 1000, altitudeTrack1); ITrack track2 = FakeTrackFactory.GetTrack(2000, 2000, altitudeTrack2); var result = _uuTrackAltitudeCondition.ConditionBetween(track1, track2); Assert.That(result == false); }
public void DetectCondition_ConditionNotFound_EventHandlerNotInvoked() { bool invoked = false; ITrack firstTrack = FakeTrackFactory.GetTrack(1000, 1000, 1000); ITrack secondTrack = FakeTrackFactory.GetTrack(1100, 1100, 1000); ITrackable airspace = FakeAirspaceGenerator.GetAirspace(0, 0, 0); airspace.Trackables = new List <ITrack>() { firstTrack, secondTrack }; _fakeCondition.ConditionBetween(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(false); _uutConditionDetector.ConditionsHandler += (s, e) => invoked = true; _uutConditionDetector.DetectCondition(airspace); Assert.That(invoked == false); }
public void DetectCondition_ConditionFound_SecondConditionCorrect() { ConditionEventArgs eventArgsReceived = null; ITrack firstTrack = FakeTrackFactory.GetTrack(1000, 1000, 1000); ITrack secondTrack = FakeTrackFactory.GetTrack(1100, 1100, 1000); ITrackable airspace = FakeAirspaceGenerator.GetAirspace(0, 0, 0); airspace.Trackables = new List <ITrack>() { firstTrack, secondTrack }; _fakeCondition.ConditionBetween(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(true); _uutConditionDetector.ConditionsHandler += (s, e) => eventArgsReceived = e; _uutConditionDetector.DetectCondition(airspace); Assert.That(eventArgsReceived.SecondConditionHolder, Is.EqualTo(secondTrack)); }
public void DetectCondition_MultipleConditions_EventHandlerInvokedCorrect(int numConditions) { int timesInvoked = 0; ITrack trackInAirspace = FakeTrackFactory.GetTrack(1000, 1000, 1000); ITrackable airspace = FakeAirspaceGenerator.GetAirspace(0, 0, 0); airspace.Trackables.Add(trackInAirspace); //There must be one track always for (int i = 0; i < numConditions; i++) { airspace.Trackables.Add(trackInAirspace); } //Because each element in the airspace is compared to each other: int expectedVisitations = numConditions * airspace.Trackables.Count / 2; _fakeCondition.ConditionBetween(Arg.Any <ITrack>(), Arg.Any <ITrack>()).Returns(true); _uutConditionDetector.ConditionsHandler += (s, e) => ++ timesInvoked; _uutConditionDetector.DetectCondition(airspace); Assert.That(timesInvoked, Is.EqualTo(expectedVisitations)); }