示例#1
0
        public void Test1(int firstPlayerScore, int secondPlayerScore, string expectAnswer)
        {
            string FirstPlayerName  = "PlayerA";
            string SecondPlayerName = "PlayerB";
            string scoreString      = TennisService.Score(FirstPlayerName, SecondPlayerName, firstPlayerScore, secondPlayerScore);

            Assert.AreEqual(expectAnswer, scoreString);
        }
        public HttpResponseMessage UpdateMatch(PlayerMatchScore model)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            PlayerMatchScore response = TennisService.UpdateMatch(model);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public HttpResponseMessage DeleteMatch(int id)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            int response = TennisService.DeleteMatch(id);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public HttpResponseMessage SearchMatches(Search search)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            IEnumerable <Match> response = TennisService.SearchMatches(search);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
        public HttpResponseMessage InsertPlayer([FromBody] string name)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            int response = TennisService.InsertPlayer(name);

            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
示例#6
0
        public void Player1_WinPoint_When_Score_Thirty_Thirty_Score_ShouldBe_Fourty_Thirty()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Increment(1, (int)GamePoint.Thirty, (int)GamePoint.Thirty);

            // Assert
            Assert.IsNotNull(score);
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.Forty);
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.Thirty);
        }
示例#7
0
        public void Score_ShouldBe_Deuce_When_Player1_WinPoint_And_Player2_Have_Advantage()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Increment(1, (int)GamePoint.Deuce, (int)GamePoint.Advantage);

            // Assert
            Assert.IsNotNull(score);
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.Deuce);
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.Deuce);
        }
示例#8
0
        public void Player2_Win_Game_When_Have_Advantage_Score_ShouldBe_Zero_Zero()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Increment(2, (int)GamePoint.Deuce, (int)GamePoint.Advantage);

            // Assert
            Assert.IsNotNull(score);
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.zero);
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.zero);
        }
示例#9
0
        public void Start_TheGame_Player1_WinPoint_First_Point_ShouldBe_Fivteen_Zero()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Increment(1, (int)GamePoint.zero, (int)GamePoint.zero);

            // Assert
            Assert.IsNotNull(score);
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.Fifteen);
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.zero);
        }
示例#10
0
        public void Player2_Take_Advantage_When_Score_Forty_Forty_Score_ShouldBe_None_Advantage()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Increment(2, (int)GamePoint.Forty, (int)GamePoint.Forty);

            // Assert
            Assert.IsNotNull(score);
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.Deuce);
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.Advantage);
        }
示例#11
0
        public void Player2_Win_Game_When_Score_thirty_Forty_Score_ShouldBe_Zero_Zero()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Increment(2, (int)GamePoint.Thirty, (int)GamePoint.Forty);

            // Assert
            Assert.IsNotNull(score);
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.zero);
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.zero);
        }
示例#12
0
        public void Player2_WinPoint_When_Score_Fivteen_zero__Score_ShouldBe_Fivteen_Fivteen()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Increment(2, (int)GamePoint.Fifteen, (int)GamePoint.zero);

            // Assert
            Assert.IsNotNull(score);
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.Fifteen);
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.Fifteen);
        }
        public HttpResponseMessage SearchData()
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            PopulateSearch         response = new PopulateSearch();
            IEnumerable <string>   player   = TennisService.PlayerSearchBar();
            IEnumerable <string>   location = TennisService.LocationSearchBar();
            IEnumerable <DateTime> date     = TennisService.DateSearchBar();

            response.Players   = player;
            response.Locations = location;
            response.Dates     = date;
            return(Request.CreateResponse(HttpStatusCode.OK, response));
        }
示例#14
0
        public void Start_TheGame_Score_ShouldBe_Zero_Zero()
        {
            // Arrange
            var service = new TennisService();

            // Act
            Score score = service.Get();

            // Assert
            Assert.IsNotNull(score);
            score.Player1.Id.Should().Be(1);
            score.Player1.Name.Should().Be("Nadal");
            score.Player1.PlayerGamePoint.Should().Be(GamePoint.zero);

            score.Player2.Id.Should().Be(2);
            score.Player2.Name.Should().Be("Federer");
            score.Player2.PlayerGamePoint.Should().Be(GamePoint.zero);
        }