Ejemplo n.º 1
0
            public void WhenAPointIsOutOfRangeItCannotBeAdded()
            {
                var point    = new ColouredPoint(Color.Red, new Point(30, 1));
                var gameGrid = new GameGrid(10, 10);

                Assert.False(gameGrid.CanAdd(new[] { point }));
            }
Ejemplo n.º 2
0
            public void WhenAddingAnOutOfRangePointReturnsFalse(int X, int Y)
            {
                var point    = new ColouredPoint(Color.Red, new Point(X, Y));
                var gameGrid = new GameGrid(10, 10);

                Assert.False(gameGrid.TryAdd(new[] { point }));
            }
Ejemplo n.º 3
0
            public void WhenGridIsEmptyPointsCanBeAdded()
            {
                var point    = new ColouredPoint(Color.Red, new Point(1, 1));
                var gameGrid = new GameGrid(10, 10);

                Assert.True(gameGrid.CanAdd(new[] { point }));
            }
Ejemplo n.º 4
0
            public void TwoPointsWithTheSameParametersAreObjectEqual(int X, int Y, string colourName)
            {
                var point1 = new ColouredPoint(Color.FromName(colourName), new Point(X, Y));
                var point2 = new ColouredPoint(Color.FromName(colourName), new Point(X, Y));

                Assert.True(point1.Equals((Object)point2));
            }
Ejemplo n.º 5
0
            public void TwoPointsWithTheSameParametersHaveSameHashCode(int X, int Y, string colourName)
            {
                var point1 = new ColouredPoint(Color.FromName(colourName), new Point(X, Y));
                var point2 = new ColouredPoint(Color.FromName(colourName), new Point(X, Y));

                Assert.AreEqual(point1.GetHashCode(), point2.GetHashCode());
            }
Ejemplo n.º 6
0
            public void TwoPointsWithDifferentParametersAreNotEqual(int X, int Y, string colourName)
            {
                var point1 = new ColouredPoint(Color.FromName(colourName), new Point(X, Y));
                var point2 = new ColouredPoint(Color.Turquoise, new Point(X + 1, Y + 1));

                Assert.False(point1.Equals(point2));
            }
Ejemplo n.º 7
0
            public void WhenConstructedPointIsSetCorrectly(int X, int Y)
            {
                var point = new Point(X, Y);
                var shape = new ColouredPoint(Color.Red, point);

                Assert.AreEqual(point, shape.Point);
            }
Ejemplo n.º 8
0
            public void ColorIsSetCorrectly(string colorName)
            {
                var color      = Color.FromName(colorName);
                var colouredPt = new ColouredPoint(color, new Point(1, 1));

                Assert.AreEqual(color, colouredPt.Color);
            }
Ejemplo n.º 9
0
            public void WhenAddingTheSamePointTwiceReturnsFalse()
            {
                var point    = new ColouredPoint(Color.Red, new Point(1, 1));
                var gameGrid = new GameGrid(10, 10);

                gameGrid.TryAdd(new[] { point });

                Assert.False(gameGrid.TryAdd(new[] { point }));
            }
Ejemplo n.º 10
0
            public void WhenADuplicatePointIsUsedItCannotBeAdded()
            {
                var point    = new ColouredPoint(Color.Red, new Point(1, 1));
                var gameGrid = new GameGrid(10, 10);

                gameGrid.TryAdd(new[] { point });

                Assert.False(gameGrid.CanAdd(new[] { point }));
            }
Ejemplo n.º 11
0
            public void WhenAPointIsAddedItIsEnumerated()
            {
                var gameGrid = new GameGrid(100, 120);
                var point    = new ColouredPoint(Color.Red, new Point(1, 1));

                gameGrid.TryAdd(new[] { point });

                var enumerator = gameGrid.GetEnumerator();

                Assert.True(enumerator.MoveNext());
                Assert.AreEqual(point, enumerator.Current);
                Assert.False(enumerator.MoveNext());
            }
Ejemplo n.º 12
0
            public void IsNotEqualToNull()
            {
                var point1 = new ColouredPoint(Color.Turquoise, new Point(1, 1));

                Assert.False(point1.Equals(null));
            }
Ejemplo n.º 13
0
            public void IsNotEqualToADifferentType()
            {
                var point1 = new ColouredPoint(Color.Turquoise, new Point(1, 1));

                Assert.False(point1.Equals(new object()));
            }