public void Slope_FlatSlope_Returns0() { Line2D sut = new Line2D(new Point(0, 0), new Point(4, 0)); decimal result = sut.Slope(); result.ShouldBe((decimal)0); }
public void Slope_AtypicalSlope_ReturnsSlope() { Line2D sut = new Line2D(new Point(0, 0), new Point(4, 4)); decimal result = sut.Slope(); result.ShouldBe((decimal)1); }
public void IntersectsWith_ParrallelLines_ReturnsFalse() { Line2D line1 = new Line2D(new Point(0, 0), new Point(1, 1)); Line2D line2 = new Line2D(new Point(0, 1), new Point(1, 2)); bool result = line1.IntersectsWith(line2); result.ShouldBe(false); }
public void IntersectsWith_IntersectingLines_ReturnsTrue() { Line2D line1 = new Line2D(new Point(0, 0), new Point(1, 1)); Line2D line2 = new Line2D(new Point(0, 4), new Point(1, 0)); bool result = line1.IntersectsWith(line2); result.ShouldBe(true); }
public void IntersectsWith_IdenticalPointsInConstructor_InvalidArgumentException() { bool didThrow = false; try { Line2D sut = new Line2D(new Point(0, 0), new Point(0, 0)); } catch (ArgumentException) { didThrow = true; } didThrow.ShouldBe(true); }
public void Slope_InfiniteSlope_ReturnsSlope() { Line2D sut = new Line2D(new Point(0, 0), new Point(0, 4)); bool thrown = false; try { sut.Slope(); } catch (DivideByZeroException) { thrown = true; } thrown.ShouldBe(true); }
public bool IntersectsWith(Line2D otherLine) { return Slope() != otherLine.Slope(); }