public void Should_not_get_the_same_hash_with_inverted_coordinates()
        {
            var a = new Coordinate(10, 100);
            var b = new Coordinate(100, 10);

            Assert.That(a.GetHashCode(), Is.Not.EqualTo(b.GetHashCode()));
        }
        public void Should_get_the_same_hash_code_with_the_same_coordinates()
        {
            var a = new Coordinate(10, 10);
            var b = new Coordinate(10, 10);

            Assert.That(a.GetHashCode(), Is.EqualTo(b.GetHashCode()));
        }
        public void Should_get_same_coordinates_when_adding_with_null()
        {
            Coordinate other = null;
            var a = new Coordinate(100, 100);

            var b = other + a;

            Assert.That(b.Equals(new Coordinate(100, 100)));
        }
        public void Should_be_possible_to_subtract_coordinates()
        {
            var a = new Coordinate(100, 200);
            var b = new Coordinate(50, 75);

            var c = a - b;

            Assert.That(c.Equals(new Coordinate(50, 125)));
        }
        public void Should_be_possible_to_add_coordinates()
        {
            var a = new Coordinate(100, 200);
            var b = new Coordinate(50, 75);

            var c = a + b;

            Assert.That(c.Equals(new Coordinate(150, 275)));
        }
Esempio n. 6
0
 private bool Equals(Coordinate other)
 {
     if (other == null) return false;
     return this.X.Equals(other.X) && this.Y.Equals(other.Y);
 }
        public void Should_not_get_zero_hash_when_one_coordinate_is_zero(int x, int y)
        {
            var c = new Coordinate(x, y);

            Assert.That(c.GetHashCode(), Is.Not.EqualTo(0));
        }