Esempio n. 1
0
        public async Task Index_ReturnsAViewResult_WithAListOfCompetitors()
        {
            // Arrange
            var mockService = new Mock <ILeaderboardService>();

            mockService.Setup(repo => repo.GetAllCompetitors()).Returns(Task.FromResult(GetTestCompetitors()));
            var controller = new CompetitorsController(mockService.Object, null);

            // Act
            var result = await controller.Index();

            // Assert
            var viewResult = Xunit.Assert.IsType <ViewResult>(result);
            var model      = Xunit.Assert.IsAssignableFrom <IEnumerable <Competitor> >(
                viewResult.ViewData.Model);

            Xunit.Assert.Equal(4, model.Count());
        }