コード例 #1
0
        public async Task GetAllTest()
        {
            var coach1 = new Coach()
            {
                Id = 1, Name = "test coach 1", Email = "*****@*****.**"
            };
            var coach2 = new Coach()
            {
                Id = 2, Name = "test coach 2", Email = "*****@*****.**"
            };
            var coaches = new List <Coach> {
                coach1, coach2
            };

            var fakeRepositoryMock = new Mock <ICoachRepository>();

            fakeRepositoryMock.Setup(x => x.GetAll()).ReturnsAsync(coaches);

            var coachService = new CoachService(fakeRepositoryMock.Object);

            var resultCoaches = await coachService.GetAll();

            Assert.Collection(resultCoaches, coach =>
            {
                Assert.Equal("test coach 1", coach.Name);
            },
                              coach =>
            {
                Assert.Equal("test coach 2", coach.Name);
            });
        }
コード例 #2
0
 // GET: Coaches
 public async Task <IActionResult> Index()
 {
     return(View(await _coachService.GetAll()));
 }