public void RetrieveATeamPlayerInTheRepo()
        {
            TeamPlayerSeasonStatisticViewModel tp = new TeamPlayerSeasonStatisticViewModel();
            int calledTPId     = 0;
            int calledSeasonId = 0;

            var mock = new Mock <ITeamPlayerRepository>(MockBehavior.Strict);

            // Filling mock with data
            mock.As <ITeamPlayerRepository>().Setup(m => m.GetTeamPlayerStatisticForASeason(It.IsAny <int>(), It.IsAny <int>()))
            .Callback((int tpId, int seasonId) =>
            {
                calledTPId     = tpId;
                calledSeasonId = seasonId;
            })
            .Returns(Task.FromResult(tp));

            // Creating the controller which we want to create
            TeamPlayerStatisticViewController controller = new TeamPlayerStatisticViewController(mock.Object);

            // configuring the context for the controler
            fakeContext(controller);

            int inputParamTPId           = 1;
            int inputParamSeasonId       = 1;
            HttpResponseMessage response = controller.Get(inputParamTPId, inputParamSeasonId).Result;

            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            var objectContent = response.Content as ObjectContent;

            // Verifying that the parameters have correctly been passed on the repo
            Assert.AreEqual(calledTPId, inputParamTPId);
            Assert.AreEqual(calledSeasonId, inputParamSeasonId);
            Assert.AreEqual(tp, objectContent.Value);
        }
Exemple #2
0
        public async Task <HttpResponseMessage> Get(int idTeamPlayer, int idSeason)
        {
            TeamPlayerSeasonStatisticViewModel tp = await this.teamPlayerRepository.GetTeamPlayerStatisticForASeason(idTeamPlayer, idSeason);

            return(Request.CreateResponse(HttpStatusCode.OK, tp));
        }