Ejemplo n.º 1
0
        public void test_the_distance_from_one_loc_to_another()
        {
            Location loc1 = new Location(5, 6);
              Location loc2 = new Location(5, 6);
              Location loc3 = new Location(5, 5);
              Location loc4 = new Location(20, -5);

              Specify.That(loc1.distance_from(loc2)).ShouldEqual(0);
              float x_dist = 5 - 5;
              float y_dist = 6 - 5;
              Specify.That(loc1.distance_from(loc3)).ShouldEqual((float)Math.Sqrt(Math.Pow(x_dist, 2) + Math.Pow(y_dist, 2)));
              x_dist = 5 - 5;
              y_dist = 5 - 6;
              Specify.That(loc3.distance_from(loc1)).ShouldEqual((float)Math.Sqrt(Math.Pow(x_dist, 2) + Math.Pow(y_dist, 2)));
              x_dist = 5 - 20;
              y_dist = 6 - -5;
              Specify.That(loc1.distance_from(loc4)).ShouldEqual((float)Math.Sqrt(Math.Pow(x_dist, 2) + Math.Pow(y_dist, 2)));
        }