Exemplo n.º 1
0
        public void RectangleOverlap_DetectsFirstRectangleContainsSecondRectangle()
        {
            var rec1 = new Rectangle(new Point() { X = -5, Y = -5 }, new Point() { X = 5, Y = 5 });

             var rec2 = new Rectangle(new Point() { X = 1, Y = 1 }, new Point() { X = 0, Y = 0 });

             rec1.Overlaps(rec2).ShouldBe(true);
        }
Exemplo n.º 2
0
 public bool ContainsAnyPortionOf(Rectangle rec)
 {
     if(DomainContains(rec.MinPoint) || DomainContains(rec.MaxPoint))
     {
         if (RangeContains(rec.MinPoint) || RangeContains(rec.MaxPoint) || rec.RangeContains(MinPoint) || rec.RangeContains(MaxPoint))
             return true;
     }
     return false;
 }
Exemplo n.º 3
0
        public void RectangleOverlap_DetectsPlusShapedIntersection()
        {
            var rec1 = new Rectangle(new Point() { X = -5, Y = 0 }, new Point() { X = 5, Y = 1 });

             var rec2 = new Rectangle(new Point() { X = 0, Y = -5 }, new Point() { X = 1, Y = 5 });

             rec1.Overlaps(rec2).ShouldBe(true);
        }
Exemplo n.º 4
0
 public bool Overlaps(Rectangle rec)
 {
     return rec.ContainsAnyPortionOf(this) || ContainsAnyPortionOf(rec);
 }
Exemplo n.º 5
0
 public void WhenRectangleCreated_ItSortsItsPointsCorrectly()
 {
     Point p1 = new Point() {X = 1, Y = 1};
      Point p2 = new Point() {X = 0, Y = 0};
      var rec = new Rectangle(p1, p2);
      rec.MinPoint.X.ShouldBe(0);
      rec.MinPoint.Y.ShouldBe(0);
      rec.MaxPoint.X.ShouldBe(1);
      rec.MaxPoint.Y.ShouldBe(1);
 }
Exemplo n.º 6
0
        public void RectanglesDoNotOverlap()
        {
            var rec1 = new Rectangle(new Point() { X = -5, Y = -5 }, new Point() { X = -4, Y = -4 });

            var rec2 = new Rectangle(new Point() { X = 5, Y = 5 }, new Point() { X = 4, Y = 4 });

            rec1.Overlaps(rec2).ShouldBe(false);
        }