Ejemplo n.º 1
0
        // GET: Coaches/Details/5
        public async Task <IActionResult> Details(long?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var coach = await _coachService.GetById((long)id);

            if (coach == null)
            {
                return(NotFound());
            }

            return(View(coach));
        }
        public async Task GetByIdTest()
        {
            var coach1 = new Coach()
            {
                Id = 1, Name = "test coach 1", Email = "*****@*****.**"
            };
            var coach2 = new Coach()
            {
                Id = 2, Name = "test coach 2", Email = "*****@*****.**"
            };

            var fakeRepositoryMock = new Mock <ICoachRepository>();

            fakeRepositoryMock.Setup(x => x.GetByID(1)).ReturnsAsync(coach1);

            var coachService = new CoachService(fakeRepositoryMock.Object);

            var result = await coachService.GetById(1);

            Assert.Equal("test coach 1", result.Name);
        }