Ejemplo n.º 1
0
        public void CanGetAllElections()
        {
            // Expected Result
            ICollection <Election>          elections = fakeElectionRepository._fakeRepository.Where(x => !x.Dormant).ToList();
            ICollection <ElectionViewModel> expected  = elections.Select(x => ElectionViewModel.ToViewModel(x)).ToList();
            // Actual Result
            ICollection <ElectionViewModel> result = _electionServices.GetAllElections();

            // Assert
            expected.Should().BeEquivalentTo(result);
        }
Ejemplo n.º 2
0
        public void CanAddElection()
        {
            //Create Additonal Election
            Election          expected     = fakeElectionRepository.GenerateAdditionalElection();
            ElectionViewModel _newElection = ElectionViewModel.ToViewModel(expected);

            //Add Election
            _electionServices.AddElection(_newElection);
            // Actual Result
            ElectionViewModel _vm    = _electionServices.GetElectionById(654321);
            Election          result = ElectionViewModel.ToDataModel(_vm);

            // Assert
            expected.Should().BeEquivalentTo(result);
        }
Ejemplo n.º 3
0
        public void CanUpdateElection()
        {
            //Create Updated Election
            Election          updatedElection  = fakeElectionRepository.GenerateUpdatedElection();
            ElectionViewModel _updatedElection = ElectionViewModel.ToViewModel(updatedElection);

            //Update Election
            _electionServices.UpdateElection(_updatedElection);
            // Expected Result
            Election expected = updatedElection;
            // Actual Result
            ElectionViewModel _vm    = _electionServices.GetElectionById(123456);
            Election          result = ElectionViewModel.ToDataModel(_vm);

            // Assert
            expected.Should().BeEquivalentTo(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Return a list of ElectionListViewModel with all elections not marked dormant
        /// </summary>
        /// <returns></returns>
        public ICollection <ElectionViewModel> GetAllElections()
        {
            ICollection <Election> elections = _electionRepository.GetAllElections();

            return(elections.Select(x => ElectionViewModel.ToViewModel(x)).ToList());
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Get Election by unique Election ID
        /// </summary>
        /// <param name="electionId">Unique Election ID</param>
        /// <returns type="ElectionViewModel">Election</returns>
        public ElectionViewModel GetElectionById(int electionId)
        {
            Election toReturn = _electionRepository.GetElection(electionId);

            return(ElectionViewModel.ToViewModel(toReturn));
        }