Beispiel #1
0
        public void CanGetAllAreas()
        {
            // Expected Result
            ICollection <Area>          areas    = fakeAreaRepository._fakeRepository.Where(x => x.Dormant == false).ToList();
            ICollection <AreaViewModel> expected = areas.Select(x => AreaViewModel.ToViewModel(x)).ToList();
            // Actual Result
            ICollection <AreaViewModel> result = _areaServices.GetAllAreas();

            // Assert
            expected.Should().BeEquivalentTo(result);
        }
Beispiel #2
0
 public static VoteViewModel ToViewModel(Vote x)
 {
     return(new VoteViewModel
     {
         ElectionId = x.ElectionId,
         AreaId = x.AreaId,
         CandidateId = x.CandidateId ?? null,
         Comment = x.Comment,
         Area = x.Area != null?AreaViewModel.ToViewModel(x.Area) : null,
                    Candidate = x.Candidate != null?CandidateViewModel.ToViewModel(x.Candidate, null) : null
     });
 }
Beispiel #3
0
        public void CanAddArea()
        {
            //Create Additonal Area
            Area          expected = fakeAreaRepository.GenerateAdditionalArea();
            AreaViewModel _newArea = AreaViewModel.ToViewModel(expected);

            //Add Area
            _areaServices.AddArea(_newArea);
            // Actual Result
            Area result = fakeAreaRepository._fakeRepository.Last();

            // Assert
            expected.Should().BeEquivalentTo(result);
        }
Beispiel #4
0
        public void CanUpdateArea()
        {
            //Create Updated Area
            Area          updatedArea  = fakeAreaRepository.GenerateUpdatedArea();
            AreaViewModel _updatedArea = AreaViewModel.ToViewModel(updatedArea);

            //Update Area
            _areaServices.UpdateArea(_updatedArea);
            // Expected Result
            Area expected = updatedArea;
            // Actual Result
            Area result = fakeAreaRepository._fakeRepository.First();

            // Assert
            expected.Should().BeEquivalentTo(result);
        }
Beispiel #5
0
        public ICollection <AreaViewModel> GetAllAreas()
        {
            ICollection <Area> areas = _areaRepository.GetAllAreas();

            return(areas.Select(x => AreaViewModel.ToViewModel(x)).ToList());
        }