public CorrectViewModelTest() { _teams = GenerateTeamList(); _enabledTeams = new Teams(); foreach(Team team in _teams) { if (team.TeamEnabled) { _enabledTeams.Add(team); } } _quizzes = GenerateQuizzesList(); _rounds = _quizzes.Where(q => q.QuizEnabled).FirstOrDefault().QuizRounds; _teamServiceMock = new Mock<ITeamService>(); _teamServiceMock.Setup(tS => tS.GetAllTeams()).ReturnsAsync(_teams); _teamServiceMock.Setup(tS => tS.PatchTeamScore(It.IsAny<int>(), It.IsAny<int>())).ReturnsAsync(true); _roundServiceMock = new Mock<IRoundService>(); _roundServiceMock.Setup(rS => rS.GetAllRoundsByEnabledQuiz()).ReturnsAsync(_rounds); _navigationServiceExMock = new Mock<INavigationServiceEx>(); _sut = new CorrectViewModel(_teamServiceMock.Object, _roundServiceMock.Object, _navigationServiceExMock.Object); }
public void Constructor_ShouldLoadEnabledTeamsAndRoundsOfEnabledQuiz() { //Act var sut = new CorrectViewModel(_teamServiceMock.Object, _roundServiceMock.Object, _navigationServiceExMock.Object); //Assert Assert.Equal(_enabledTeams, sut.EnabledTeams); Assert.Equal(_rounds, sut.QuizRounds); _teamServiceMock.Verify(tS => tS.GetAllTeams(), Times.AtLeastOnce); //Normally it's once but since the ViewModel is created in the Constructor of this test it's twice _roundServiceMock.Verify(rS => rS.GetAllRoundsByEnabledQuiz(), Times.AtLeastOnce); //Normally it's once but since the ViewModel is created in the Constructor of this test it's twice }