public void Simple_Status_Constituency() { ICountyRepository countyRepository = Substitute.For <ICountyRepository>(); var f = new Fixture(); var county = f.Create <County>(); var constituency = CreateConstituency(county.GetMasterDataRef()); countyRepository.GetById(Arg.Any <Guid>()).Returns(county); var constituencyRepository = new ConstituencyRepository(ContextConnection(), countyRepository); constituencyRepository.Save(constituency); constituencyRepository.SetInactive(constituency); var inactive = constituencyRepository.GetById(constituency.Id); Assert.That(inactive.Status == EntityStatus.Inactive); constituencyRepository.SetActive(constituency); var active = constituencyRepository.GetById(constituency.Id); Assert.That(active.Status == EntityStatus.Active); constituencyRepository.SetAsDeleted(constituency); var deleted = constituencyRepository.GetById(constituency.Id); Assert.That(deleted.Status == EntityStatus.Deleted); }
public ValidationResultInfo Validate(Constituency itemToValidate) { var validation = base.Validate(itemToValidate, GetAll(true).ToList()); var county = _countyRepository.GetById(itemToValidate.County.Id); if (county == null) { validation.Results.Add(new ValidationResult("Invalid constituency reference.")); } return(validation); }
public void SimpeHydrate_Constituency() { ICountyRepository countyRepository = Substitute.For <ICountyRepository>(); var f = new Fixture(); var county = f.Create <County>(); var constituency = CreateConstituency(county.GetMasterDataRef()); countyRepository.GetById(Arg.Any <Guid>()).Returns(county); var constituencyRepository = new ConstituencyRepository(ContextConnection(), countyRepository); var id = constituencyRepository.Save(constituency); Assert.IsNotNull(id); Assert.AreEqual(id, constituency.Id); }
public void SimpeDeHydrateAll_Constituency() { ICountyRepository countyRepository = Substitute.For <ICountyRepository>(); var f = new Fixture(); var county = f.Create <County>(); var constituency = CreateConstituency(county.GetMasterDataRef()); countyRepository.GetById(Arg.Any <Guid>()).Returns(county); var constituencyRepository = new ConstituencyRepository(ContextConnection(), countyRepository); constituencyRepository.Save(constituency); var owner = constituencyRepository.GetAll(); Assert.That(owner.Any()); }
public CountyViewModel Get(Guid id) { return(new CountyViewModel(_countyRepository.GetById(id))); }