Exemplo n.º 1
0
        public IEnumerator <object[]> GetEnumerator()
        {
            var strategyMock = new Mock <ISittingStrategy>();
            var seats1       = new SeatDay11[2, 2]
            {
                { new SeatDay11('.'), new SeatDay11('L') },
                { new SeatDay11('.'), new SeatDay11('#') }
            };

            var seats2 = new SeatDay11[3, 2]
            {
                { new SeatDay11('.'), new SeatDay11('L') },
                { new SeatDay11('.'), new SeatDay11('#') },
                { new SeatDay11('#'), new SeatDay11('#') }
            };

            var airportSeat1 = new AirportSeatsDay11(strategyMock.Object, seats1);
            var airportSeat2 = new AirportSeatsDay11(strategyMock.Object, seats2);

            yield return(new object[] {
                airportSeat1, 1
            });

            yield return(new object[] {
                airportSeat2, 3
            });
        }
        public void Should_ShouldChangeState(SeatDay11 seat, int neighbours, bool expected)
        {
            var strategy = new InVisionNeighbourStrategy();
            var result   = strategy.ShouldChangeState(seat, neighbours);

            Assert.Equal(expected, result);
        }
            public IEnumerator <object[]> GetEnumerator()
            {
                var seats1 = new SeatDay11[2, 2]
                {
                    { new SeatDay11('.'), new SeatDay11('.') },
                    { new SeatDay11('.'), new SeatDay11('#') }
                };

                var seats2 = new SeatDay11[3, 2]
                {
                    { new SeatDay11('.'), new SeatDay11('L') },
                    { new SeatDay11('.'), new SeatDay11('#') },
                    { new SeatDay11('#'), new SeatDay11('#') }
                };

                yield return(new object[] {
                    seats1, 0, 0, 1
                });

                yield return(new object[] {
                    seats2, 1, 0, 3
                });

                yield return(new object[] {
                    seats2, 1, 1, 2
                });
            }
Exemplo n.º 4
0
        public void Should_ChangeState(char state, char expected, bool expectedChange)
        {
            var seat        = new SeatDay11(state);
            var stateChange = seat.ChangeState();

            Assert.Equal(expectedChange, stateChange);
            Assert.Equal(expected, seat.SeatState);
        }
Exemplo n.º 5
0
        public IEnumerator <object[]> GetEnumerator()
        {
            var strategyMock1 = new Mock <ISittingStrategy>();
            var strategyMock2 = new Mock <ISittingStrategy>();
            var strategyMock3 = new Mock <ISittingStrategy>();

            var seats1 = new SeatDay11[2, 2]
            {
                { new SeatDay11('#'), new SeatDay11('L') },
                { new SeatDay11('L'), new SeatDay11('#') }
            };

            var seats2 = new SeatDay11[2, 2]
            {
                { new SeatDay11('.'), new SeatDay11('.') },
                { new SeatDay11('.'), new SeatDay11('.') }
            };

            strategyMock1.Setup(s => s.ShouldChangeState(It.IsAny <SeatDay11>(), It.IsAny <int>()))
            .Returns(true);

            strategyMock2.Setup(s => s.ShouldChangeState(It.IsAny <SeatDay11>(), It.IsAny <int>()))
            .Returns(false);


            strategyMock3.Setup(s => s.CountOccupiedNeighbours(It.IsAny <SeatDay11[, ]>(), 1, 1)).Returns(10);
            strategyMock3.SetReturnsDefault(false);
            strategyMock3.Setup(s => s.ShouldChangeState(It.IsAny <SeatDay11>(), 10))
            .Returns(true);


            var airportSeats1 = new AirportSeatsDay11(strategyMock1.Object, seats1);
            var airportSeats2 = new AirportSeatsDay11(strategyMock2.Object, seats1);
            var airportSeats3 = new AirportSeatsDay11(strategyMock3.Object, seats1);
            var airportSeats4 = new AirportSeatsDay11(strategyMock1.Object, seats2);

            yield return(new object[] {
                airportSeats1, true
            });

            yield return(new object[] {
                airportSeats2, false
            });

            yield return(new object[] {
                airportSeats3, true
            });

            yield return(new object[] {
                airportSeats4, false
            });
        }
            public IEnumerator <object[]> GetEnumerator()
            {
                var seatsInput = new List <string>()
                {
                    "L.LL",
                    "LL#L",
                    "L.#.",
                    "LL##",
                };

                //such big object should not be created in unit testes?
                //for x for ? ^ ^"
                var seats1 = new SeatDay11[4, 4];

                for (int i = 0; i < 4; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        seats1[i, j] = new SeatDay11(seatsInput[i][j]);
                    }
                }

                yield return(new object[] {
                    seats1, 0, 0, 0
                });

                yield return(new object[] {
                    seats1, 1, 0, 1
                });

                yield return(new object[] {
                    seats1, 2, 2, 3
                });

                yield return(new object[] {
                    seats1, 1, 2, 1
                });
            }
Exemplo n.º 7
0
        public void Should_IsEmpty(char state, bool expected)
        {
            var seat = new SeatDay11(state);

            Assert.Equal(expected, seat.IsEmpty());
        }