public void Simple_Status_Race() { IElectionRepository electionRepository = Substitute.For <IElectionRepository>(); var f = new Fixture(); var election = f.Create <Election>(); var race = Create(election.GetMasterDataRef()); electionRepository.GetById(Arg.Any <Guid>()).Returns(election); var raceRepository = new RaceRepository(ContextConnection(), electionRepository); raceRepository.Save(race); raceRepository.SetInactive(race); var inactive = raceRepository.GetById(race.Id); Assert.That(inactive.Status == EntityStatus.Inactive); raceRepository.SetActive(race); var active = raceRepository.GetById(race.Id); Assert.That(active.Status == EntityStatus.Active); raceRepository.SetAsDeleted(race); var deleted = raceRepository.GetById(race.Id); Assert.That(deleted.Status == EntityStatus.Deleted); }
public ValidationResultInfo Validate(Race itemToValidate) { var validation = base.Validate(itemToValidate, GetAll(true).ToList()); var elction = _electionRepository.GetById(itemToValidate.Election.Id); if (elction == null) { validation.Results.Add(new ValidationResult("Invalid election reference.")); } return(validation); }
public void SimpeHydrate_Race() { IElectionRepository electionRepository = Substitute.For <IElectionRepository>(); var f = new Fixture(); var election = f.Create <Election>(); var race = Create(election.GetMasterDataRef()); electionRepository.GetById(Arg.Any <Guid>()).Returns(election); var raceRepository = new RaceRepository(ContextConnection(), electionRepository); var id = raceRepository.Save(race); Assert.IsNotNull(id); Assert.AreEqual(id, race.Id); }
public void SimpeDeHydrateAll_Race() { IElectionRepository electionRepository = Substitute.For <IElectionRepository>(); var f = new Fixture(); var election = f.Create <Election>(); var race = Create(election.GetMasterDataRef()); electionRepository.GetById(Arg.Any <Guid>()).Returns(election); var raceRepository = new RaceRepository(ContextConnection(), electionRepository); raceRepository.Save(race); var owner = raceRepository.GetAll(); Assert.That(owner.Any()); }
public async Task <Election> GetElectionByIdAsync(int?id) { return(await Task.FromResult(_electionRepository.GetById(id.Value))); }