public void Init()
 {
     fakeFootballRepo = new FootballRepository();
     fakePlayerRepo = new FakePlayerRepository();
     playerValidatorService = new PlayerValidatorService(new FakeDialogService());
     playerMatchViewModel = new PlayerMatchViewModel(fakeFootballRepo);
     playerViewModel = new PlayerViewModel(fakeFootballRepo, playerMatchViewModel, playerValidatorService);
 }
        public void PlayerViewModel_WhenUpdateButtonClickedAndDataGridIsInvalidSendErrorToUserIsCalled()
        {
            //Arrange
            var mockFootballRepo = MockRepository.GenerateMock<IFootballRepository>();
            var mockPlayerValidatorService = MockRepository.GenerateMock<IPlayerValidatorService>();
            var mockPlayerViewModel = new PlayerViewModel(mockFootballRepo, playerMatchViewModel, mockPlayerValidatorService);
            mockPlayerValidatorService.Stub(x => x.DataGridIsValid()).Return(false);

            //Act
            mockPlayerViewModel.UpdatePlayersCommand.Execute(null);

            //Assert
            mockPlayerValidatorService.AssertWasCalled(x => x.SendErrorToUser());
        }
 public MatchViewModel()
 {
     _footballRepository = new FootballRepository(new FootballEntities());
     _playerMatchViewModel = new PlayerMatchViewModel(_footballRepository);
     _dialogService = new DialogService();
     _playerValidatorService = new PlayerValidatorService(_dialogService);
     _matchValidatorService = new MatchValidatorService(_playerMatchViewModel, _dialogService);
     _mailerService = new MailerService(_playerMatchViewModel, _playerMatchViewModel.PlayerMatches, _teams);
     ButtonViewModel = new ButtonViewModel(_footballRepository, _playerMatchViewModel, _matchValidatorService, _mailerService);
     PlayerViewModel = new PlayerViewModel(_footballRepository, _playerMatchViewModel, _playerValidatorService);
     MatchButtonViewModel = new MatchButtonViewModel(_footballRepository, this, new DialogSelectionService());
     InitialiseMatchesAndTeams();
     _selectionAlgorithms = InitialiseSelectionAlgorithms();
     _selectedAlgorithm = _selectionAlgorithms.First();
     ButtonViewModel.SelectedAlgorithm = _selectedAlgorithm;
 }
        public void PlayerViewModel_WhenUpdateButtonClickedAndDataGridIsValidSaveWasCalledOnFootballRepository()
        {
            //Arrange
            var mockFootballRepo = MockRepository.GenerateMock<IFootballRepository>();
            var mockPlayerValidatorService = MockRepository.GenerateMock<IPlayerValidatorService>();
            var mockPlayerMatchViewModel = MockRepository.GenerateMock<IPlayerMatchViewModel>();
            var mockPlayerViewModel = new PlayerViewModel(mockFootballRepo, mockPlayerMatchViewModel, mockPlayerValidatorService);
            mockPlayerViewModel.Players = fakePlayerRepo.GetTenValidPlayers();
            mockPlayerValidatorService.Stub(x => x.DataGridIsValid()).Return(true);
            mockFootballRepo.Stub(x => x.Save());

            //Act
            mockPlayerViewModel.UpdatePlayersCommand.Execute(null);

            //Assert
            mockFootballRepo.AssertWasCalled(x => x.Save());
        }