public void SetUp() { _coordinatesMock = NSubstitute.Substitute.For <IAddressCoordinates>(); _repoMock = NSubstitute.Substitute.For <IGenericRepository <CachedAddress> >(); _repoMock.AsQueryable().ReturnsForAnyArgs(new List <CachedAddress>() { new CachedAddress() { StreetName = "Jens Baggesens Vej", StreetNumber = "44", ZipCode = 8210, Town = "Aarhus V", IsDirty = true, DirtyString = "Jens Baggesens Vej 44, 8210 Aarhus V" }, new CachedAddress() { StreetName = "Katrinebjergvej", StreetNumber = "93b", ZipCode = 8200, Town = "Aarhus N", IsDirty = false, DirtyString = "Katrinebjergvej 93b, 8200 Aarhus N" } }.AsQueryable()); _laundryMock = NSubstitute.Substitute.For <IAddressLaunderer>(); _laundryMock.WhenForAnyArgs(x => x.Launder(new Address())).DoNotCallBase(); _uut = new CachedAddressLaunderer(_repoMock, _laundryMock, _coordinatesMock); }
public UpdateService(IGenericRepository <Employment> emplRepo, IGenericRepository <OrgUnit> orgRepo, IGenericRepository <Person> personRepo, IGenericRepository <CachedAddress> cachedRepo, IGenericRepository <PersonalAddress> personalAddressRepo, IAddressLaunderer actualLaunderer, IAddressCoordinates coordinates, IDbUpdaterDataProvider dataProvider, IMailSender mailSender, IAddressHistoryService historyService, IGenericRepository <DriveReport> reportRepo, IDriveReportService driveService, ISubstituteService subService, IGenericRepository <Substitute> subRepo) { _emplRepo = emplRepo; _orgRepo = orgRepo; _personRepo = personRepo; _cachedRepo = cachedRepo; _personalAddressRepo = personalAddressRepo; _actualLaunderer = actualLaunderer; _coordinates = coordinates; _dataProvider = dataProvider; _mailSender = mailSender; _historyService = historyService; _reportRepo = reportRepo; _driveService = driveService; _subService = subService; _subRepo = subRepo; _driveService = driveService; _logger = NinjectWebKernel.CreateKernel().Get <ILogger>(); }
public UpdateService(IGenericRepository <Employment> emplRepo, IGenericRepository <OrgUnit> orgRepo, IGenericRepository <Person> personRepo, IGenericRepository <CachedAddress> cachedRepo, IGenericRepository <PersonalAddress> personalAddressRepo, IAddressLaunderer actualLaunderer, IAddressCoordinates coordinates, IDbUpdaterDataProvider dataProvider, IMailSender mailSender, IAddressHistoryService historyService, IGenericRepository <Report> reportRepo, IReportService <Report> reportService, ISubstituteService subService, IGenericRepository <Substitute> subRepo, IGenericRepository <VacationBalance> vacationBalanceRepo) { _emplRepo = emplRepo; _orgRepo = orgRepo; _personRepo = personRepo; _cachedRepo = cachedRepo; _personalAddressRepo = personalAddressRepo; _actualLaunderer = actualLaunderer; _coordinates = coordinates; _dataProvider = dataProvider; _mailSender = mailSender; _historyService = historyService; _reportRepo = reportRepo; _reportService = reportService; _subService = subService; _subRepo = subRepo; _vacationBalanceRepo = vacationBalanceRepo; }
//GET: odata/Addresses public AddressesController(IGenericRepository <Address> repository, IGenericRepository <Person> personRepo, IGenericRepository <Employment> employmentRepo, IAddressLaunderer launderer, IAddressCoordinates coordinates, IGenericRepository <CachedAddress> cachedAddressRepo, IGenericRepository <PersonalAddress> personalAddressRepo) : base(repository, personRepo) { _employmentRepo = employmentRepo; _launderer = launderer; _coordinates = coordinates; _cachedAddressRepo = cachedAddressRepo; _personalAddressRepo = personalAddressRepo; }
public void SetUp() { var emplList = new List <Employment>(); var emplIdCount = 0; _emplRepoMock = NSubstitute.Substitute.For <IGenericRepository <Employment> >(); _orgUnitRepoMock = NSubstitute.Substitute.For <IGenericRepository <OrgUnit> >(); _personRepoMock = NSubstitute.Substitute.For <IGenericRepository <Person> >(); _cachedAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <CachedAddress> >(); _personalAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <PersonalAddress> >(); _actualLaunderer = NSubstitute.Substitute.For <IAddressLaunderer>(); _coordinates = NSubstitute.Substitute.For <IAddressCoordinates>(); _dataProvider = NSubstitute.Substitute.For <IDbUpdaterDataProvider>(); _workAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <WorkAddress> >(); _mailSenderMock = NSubstitute.Substitute.For <IMailSender>(); _vacationBalanceRepo = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.VacationBalance> >(); _emplRepoMock.AsQueryable().Returns(emplList.AsQueryable()); _emplRepoMock.Insert(new Employment()).ReturnsForAnyArgs(x => x.Arg <Employment>()).AndDoes(x => emplList.Add(x.Arg <Employment>())).AndDoes(x => x.Arg <Employment>().Id = emplIdCount).AndDoes(x => emplIdCount++); _subRepo = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.Substitute> >(); _reportRepo = NSubstitute.Substitute.For <IGenericRepository <Report> >(); _repotService = NSubstitute.Substitute.For <IReportService <Report> >(); _subservice = NSubstitute.Substitute.For <ISubstituteService>(); _orgUnitRepoMock.AsQueryable().Returns(new List <OrgUnit>() { new OrgUnit() { Level = 0, OrgId = 1, LongDescription = "IT Minds, Aarhus", ShortDescription = "ITM", HasAccessToFourKmRule = false, Id = 1, } }.AsQueryable()); _personRepoMock.AsQueryable().Returns(new List <Person>() { new Person() { Id = 1, } }.AsQueryable()); _uut = new UpdateService(_emplRepoMock, _orgUnitRepoMock, _personRepoMock, _cachedAddressRepoMock, _personalAddressRepoMock, _actualLaunderer, _coordinates, _dataProvider, _mailSenderMock, NSubstitute.Substitute.For <IAddressHistoryService>(), _reportRepo, _repotService, _subservice, _subRepo, _vacationBalanceRepo); }
public void SetUp() { var orgList = new List <OrgUnit>(); var orgIdCount = 0; var cachedAddressList = new List <CachedAddress>(); var cachedIdCount = 0; _emplRepoMock = NSubstitute.Substitute.For <IGenericRepository <Employment> >(); _orgUnitRepoMock = NSubstitute.Substitute.For <IGenericRepository <OrgUnit> >(); _personRepoMock = NSubstitute.Substitute.For <IGenericRepository <Person> >(); _cachedAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <CachedAddress> >(); _personalAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <PersonalAddress> >(); _actualLaunderer = NSubstitute.Substitute.For <IAddressLaunderer>(); _coordinates = NSubstitute.Substitute.For <IAddressCoordinates>(); _dataProvider = NSubstitute.Substitute.For <IDbUpdaterDataProvider>(); _mailSender = NSubstitute.Substitute.For <IMailSender>(); _vacationBalanceRepo = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.VacationBalance> >(); _orgUnitRepoMock.AsQueryable().Returns(orgList.AsQueryable()); _orgUnitRepoMock.Insert(new OrgUnit()).ReturnsForAnyArgs(x => x.Arg <OrgUnit>()).AndDoes(x => orgList.Add(x.Arg <OrgUnit>())).AndDoes(x => x.Arg <OrgUnit>().Id = orgIdCount).AndDoes(x => orgIdCount++); _cachedAddressRepoMock.Insert(new CachedAddress()).ReturnsForAnyArgs(x => x.Arg <CachedAddress>()).AndDoes(x => cachedAddressList.Add(x.Arg <CachedAddress>())).AndDoes(x => x.Arg <CachedAddress>().Id = cachedIdCount).AndDoes(x => cachedIdCount++); _cachedAddressRepoMock.AsQueryable().Returns(cachedAddressList.AsQueryable()); _subRepo = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.Substitute> >(); _reportRepo = NSubstitute.Substitute.For <IGenericRepository <Report> >(); _repotService = NSubstitute.Substitute.For <IReportService <Report> >(); _subservice = NSubstitute.Substitute.For <ISubstituteService>(); _actualLaunderer.Launder(new Address()).ReturnsForAnyArgs(x => x.Arg <CachedAddress>()); _uut = new UpdateService(_emplRepoMock, _orgUnitRepoMock, _personRepoMock, _cachedAddressRepoMock, _personalAddressRepoMock, _actualLaunderer, _coordinates, _dataProvider, _mailSender, NSubstitute.Substitute.For <IAddressHistoryService>(), _reportRepo, _repotService, _subservice, _subRepo, _vacationBalanceRepo); }
public void SetUp() { var personList = new List <Person>(); var emplList = new List <Employment>(); var emplIdCount = 0; var personIdCount = 0; var cachedAddressList = new List <CachedAddress>(); var cachedIdCount = 0; var personalAddressList = new List <PersonalAddress>(); var personalIdCount = 0; _emplRepoMock = NSubstitute.Substitute.For <IGenericRepository <Employment> >(); _orgUnitRepoMock = NSubstitute.Substitute.For <IGenericRepository <OrgUnit> >(); _personRepoMock = NSubstitute.Substitute.For <IGenericRepository <Person> >(); _cachedAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <CachedAddress> >(); _personalAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <PersonalAddress> >(); _actualLaunderer = NSubstitute.Substitute.For <IAddressLaunderer>(); _coordinates = NSubstitute.Substitute.For <IAddressCoordinates>(); _dataProvider = NSubstitute.Substitute.For <IDbUpdaterDataProvider>(); _workAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <WorkAddress> >(); _mailSenderMock = NSubstitute.Substitute.For <IMailSender>(); _subRepo = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.Substitute> >(); _reportRepo = NSubstitute.Substitute.For <IGenericRepository <Report> >(); _repotService = NSubstitute.Substitute.For <IReportService <Report> >(); _subservice = NSubstitute.Substitute.For <ISubstituteService>(); _vacationBalanceRepo = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.VacationBalance> >(); _personRepoMock.AsQueryable().Returns(personList.AsQueryable()); _personRepoMock.Insert(new Person()).ReturnsForAnyArgs(x => x.Arg <Person>()).AndDoes(x => personList.Add(x.Arg <Person>())).AndDoes(x => x.Arg <Person>().Id = personIdCount).AndDoes(x => personIdCount++); _emplRepoMock.AsQueryable().Returns(emplList.AsQueryable()); _emplRepoMock.Insert(new Employment()).ReturnsForAnyArgs(x => x.Arg <Employment>()).AndDoes(x => emplList.Add(x.Arg <Employment>())).AndDoes(x => x.Arg <Employment>().Id = emplIdCount).AndDoes(x => emplIdCount++); _cachedAddressRepoMock.Insert(new CachedAddress()).ReturnsForAnyArgs(x => x.Arg <CachedAddress>()).AndDoes(x => cachedAddressList.Add(x.Arg <CachedAddress>())).AndDoes(x => x.Arg <CachedAddress>().Id = cachedIdCount).AndDoes(x => cachedIdCount++); cachedAddressList.Add(new CachedAddress() { Id = 999, StreetName = "Katrinebjergvej", StreetNumber = "93B", ZipCode = 8200, Town = "Aarhus N", DirtyString = "Katrinebjergvej 93B, 8200 Aarhus N", IsDirty = false }); _cachedAddressRepoMock.AsQueryable().Returns(cachedAddressList.AsQueryable()); _personalAddressRepoMock.Insert(new PersonalAddress()).ReturnsForAnyArgs(x => x.Arg <PersonalAddress>()).AndDoes(x => personalAddressList.Add(x.Arg <PersonalAddress>())).AndDoes(x => x.Arg <PersonalAddress>().Id = personalIdCount).AndDoes(x => personalIdCount++); _personalAddressRepoMock.AsQueryable().Returns(personalAddressList.AsQueryable()); _actualLaunderer.Launder(new Address()).ReturnsForAnyArgs(x => x.Arg <CachedAddress>()); _uut = new UpdateService(_emplRepoMock, _orgUnitRepoMock, _personRepoMock, _cachedAddressRepoMock, _personalAddressRepoMock, _actualLaunderer, _coordinates, _dataProvider, _mailSenderMock, NSubstitute.Substitute.For <IAddressHistoryService>(), _reportRepo, _repotService, _subservice, _subRepo, _vacationBalanceRepo); _orgUnitRepoMock.AsQueryable().ReturnsForAnyArgs(new List <OrgUnit>() { new OrgUnit() { Id = 1, OrgId = 1, ShortDescription = "ITM", LongDescription = "IT Minds, Aarhus", Level = 0, HasAccessToFourKmRule = false, }, new OrgUnit() { Id = 2, OrgId = 2, ShortDescription = "ITMB", LongDescription = "IT Minds, Aarhus child", Level = 1, ParentId = 1, HasAccessToFourKmRule = false, } }.AsQueryable()); }