public void Init()
 {
     fakeFootballRepo = new FootballRepository();
     fakePlayerMatchRepo = new FakePlayerMatchRepository();
     playerMatchViewModel = new PlayerMatchViewModel(fakeFootballRepo);
     matchValidatorService = new MatchValidatorService(playerMatchViewModel, new FakeDialogService());
     mailerService = new MailerService(playerMatchViewModel,fakeFootballRepo);
     buttonViewModel = new ButtonViewModel(fakeFootballRepo, playerMatchViewModel, matchValidatorService, mailerService);
 }
 public void Init()
 {
     fakeFootballRepo = new FootballRepository();
     fakeMatchRepo = new FakeMatchRepository();
     matchViewModel = new MatchViewModel(fakeFootballRepo);
     playerMatchViewModel = new PlayerMatchViewModel(fakeFootballRepo);
     matchButtonViewModel = new MatchButtonViewModel(fakeFootballRepo, matchViewModel, new FakeDialogSelectionService());
     fakeMailerService = new MailerService(playerMatchViewModel, fakeFootballRepo);
     buttonViewModel = new ButtonViewModel(fakeFootballRepo, playerMatchViewModel, new FakeMatchValidatorService(true), fakeMailerService);
     matchViewModel.PlayerMatchViewModel = playerMatchViewModel;
     matchViewModel.ButtonViewModel = buttonViewModel;
 }
        public void ButtonViewModel_WhenAutoPickButtonIsClickedAndDataGridIsInvalidSendErrorToUserIsCalled()
        {
            //Arrange
            var mockMatchValidatorService = MockRepository.GenerateMock<IMatchValidatorService>();
            var mockButtonViewModel = new ButtonViewModel(fakeFootballRepo, playerMatchViewModel, mockMatchValidatorService, mailerService);
            mockMatchValidatorService.Stub(x => x.DataGridIsValid()).Return(false);

            //Act
            mockButtonViewModel.AutoPickCommand.Execute(null);

            //Assert
            mockMatchValidatorService.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 ButtonViewModel_WhenUpdateButtonClickedAndDataGridIsValidSaveWasCalledOnFootballRepository()
        {
            //Arrange
            var mockFootballRepo = MockRepository.GenerateMock<IFootballRepository>();
            var mockButtonViewModel = new ButtonViewModel(mockFootballRepo, new PlayerMatchViewModel(mockFootballRepo), matchValidatorService, mailerService);
            mockButtonViewModel.PlayerMatches = fakePlayerMatchRepo.GetTenPlayerMatches(1);
            mockFootballRepo.Stub(x => x.Save());

            //Act
            mockButtonViewModel.UpdateCommand.Execute(null);

            //Assert
            mockFootballRepo.AssertWasCalled(x => x.Save());
        }
        public void ButtonViewModel_WhenEmailTeamsIsClickedAndDataGridIsCompleteSendTeamsIsCalled()
        {
            //Arrange
            var mockMailerService = MockRepository.GenerateMock<IMailerService>();
            var mockButtonViewModel = new ButtonViewModel(fakeFootballRepo, playerMatchViewModel, matchValidatorService, mockMailerService);
            mockMailerService.Stub(x => x.SendTeams()).Return(true);

            //Act
            mockButtonViewModel.EmailTeamsCommand.Execute(null);

            //Assert
            mockMailerService.AssertWasCalled(x => x.SendTeams());
        }
        public void ButtonViewModel_WhenEmailStatsIsClickedAndEmailHasntBeenSentNoMessageToUser()
        {
            //Arrange
            var mockMailerService = MockRepository.GenerateMock<IMailerService>();
            var mockButtonViewModel = new ButtonViewModel(fakeFootballRepo, playerMatchViewModel, matchValidatorService, mockMailerService);
            mockMailerService.Stub(x => x.SendStats()).Return(false);

            //Act
            mockButtonViewModel.EmailStatsCommand.Execute(null);

            //Assert
            mockMailerService.AssertWasNotCalled(x => x.SendOKToUser());
        }