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);
        }
Exemplo n.º 2
0
        public void Setup()
        {
            ICustomSettings customSettings = new CustomSettings();
            IUrlDefinitions urlDefinitions = new UrlDefinitions(customSettings);

            uut = new AddressLaundering(urlDefinitions);
        }
Exemplo n.º 3
0
 public UpdateService(IGenericRepository <Employment> emplRepo,
                      IGenericRepository <OrgUnit> orgRepo,
                      IGenericRepository <Person> personRepo,
                      IGenericRepository <CachedAddress> cachedRepo,
                      IGenericRepository <PersonalAddress> personalAddressRepo,
                      IAddressLaunderer actualLaunderer,
                      IAddressCoordinates coordinates,
                      IDbUpdaterDataProvider dataProvider,
                      IMailService mailService,
                      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;
     _mailService         = mailService;
     _historyService      = historyService;
     _reportRepo          = reportRepo;
     _driveService        = driveService;
     _subService          = subService;
     _subRepo             = subRepo;
     _driveService        = driveService;
     _logger = NinjectWebKernel.GetKernel().Get <ILogger>();
 }
Exemplo n.º 4
0
        public APIService(
            IGenericRepository <OrgUnit> orgUnitRepo,
            IGenericRepository <CachedAddress> cachedRepo,
            IAddressLaunderer actualLaunderer,
            IAddressCoordinates coordinates,
            IGenericRepository <Person> personRepo,
            ISubstituteService subService,
            IGenericRepository <Substitute> subRepo,
            IGenericRepository <Report> reportRepo,
            IReportService <Report> reportService,
            ILogger <APIService> logger
            )
        {
            _orgUnitRepo     = orgUnitRepo;
            _cachedRepo      = cachedRepo;
            _actualLaunderer = actualLaunderer;
            _coordinates     = coordinates;
            _personRepo      = personRepo;
            _subService      = subService;
            _subRepo         = subRepo;
            _reportRepo      = reportRepo;
            _reportService   = reportService;
            _logger          = logger;

            _launderer = new CachedAddressLaunderer(_cachedRepo, _actualLaunderer, _coordinates);

            // manually handle changes on these large datasets to improve performance
            _orgUnitRepo.SetChangeTrackingEnabled(false);
            _personRepo.SetChangeTrackingEnabled(false);
            _subRepo.SetChangeTrackingEnabled(false);
            _reportRepo.SetChangeTrackingEnabled(false);
        }
Exemplo n.º 5
0
 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(IServiceProvider provider) : base(provider)
 {
     _employmentRepo      = provider.GetService <IGenericRepository <Employment> >();
     _launderer           = provider.GetService <IAddressLaunderer>();
     _coordinates         = provider.GetService <IAddressCoordinates>();
     _cachedAddressRepo   = provider.GetService <IGenericRepository <CachedAddress> >();
     _personalAddressRepo = provider.GetService <IGenericRepository <PersonalAddress> >();
 }
Exemplo n.º 7
0
 //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;
 }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        public APIService(IServiceProvider provider)
        {
            _orgUnitRepo           = provider.GetService <IGenericRepository <OrgUnit> >();
            _cachedRepo            = provider.GetService <IGenericRepository <CachedAddress> >();
            _actualLaunderer       = provider.GetService <IAddressLaunderer>();
            _coordinates           = provider.GetService <IAddressCoordinates>();;
            _personRepo            = provider.GetService <IGenericRepository <Person> >();;
            _subService            = provider.GetService <ISubstituteService>();;
            _subRepo               = provider.GetService <IGenericRepository <Substitute> >();;
            _reportRepo            = provider.GetService <IGenericRepository <DriveReport> >();;
            _driveService          = provider.GetService <IDriveReportService>();;
            _logger                = provider.GetService <ILogger <APIService> >();;
            _launderer             = new CachedAddressLaunderer(_cachedRepo, _actualLaunderer, _coordinates);
            _addressHistoryService = provider.GetService <AddressHistoryService>();
            _configuration         = provider.GetService <IConfiguration>();

            // manually handle changes on these large datasets to improve performance
            _orgUnitRepo.SetChangeTrackingEnabled(false);
            _personRepo.SetChangeTrackingEnabled(false);
            _subRepo.SetChangeTrackingEnabled(false);
            _reportRepo.SetChangeTrackingEnabled(false);
        }
        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> >();
            _actualLaundererMock     = NSubstitute.Substitute.For <IAddressLaunderer>();
            _coordinatesMock         = NSubstitute.Substitute.For <IAddressCoordinates>();
            _dataProviderMock        = NSubstitute.Substitute.For <IDbUpdaterDataProvider>();
            _workAddressRepoMock     = NSubstitute.Substitute.For <IGenericRepository <WorkAddress> >();
            _mailServiceMock         = NSubstitute.Substitute.For <IMailService>();
            _actualLaunderer         = NSubstitute.Substitute.For <IAddressLaunderer>();
            _coordinates             = NSubstitute.Substitute.For <IAddressCoordinates>();
            _dataProvider            = NSubstitute.Substitute.For <IDbUpdaterDataProvider>();


            _subRepo      = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.Substitute> >();
            _reportRepo   = NSubstitute.Substitute.For <IGenericRepository <DriveReport> >();
            _driveService = NSubstitute.Substitute.For <IDriveReportService>();
            _subservice   = NSubstitute.Substitute.For <ISubstituteService>();

            _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",
            });

            _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());

            _actualLaundererMock.Launder(new Address()).ReturnsForAnyArgs(x => x.Arg <CachedAddress>());

            _uut = new UpdateService(_emplRepoMock, _orgUnitRepoMock, _personRepoMock, _cachedAddressRepoMock,
                                     _personalAddressRepoMock, _actualLaunderer, _coordinates, _dataProvider, _mailServiceMock, NSubstitute.Substitute.For <IAddressHistoryService>(), _reportRepo, _driveService, _subservice, _subRepo);

            _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());

            personList.Add(new Person()
            {
                Id = 1,
            });
        }
Exemplo n.º 12
0
 public AddressCoordinates(IAddressLaunderer addressLaunderer, IUrlDefinitions urlDefinitions)
 {
     _addressLaunderer = addressLaunderer;
     _urlDefinitions   = urlDefinitions;
 }
 public CachedAddressLaunderer(IGenericRepository <CachedAddress> repo, IAddressLaunderer actualLaunderer, IAddressCoordinates coordinates)
 {
     _repo            = repo;
     _actualLaunderer = actualLaunderer;
     _coordinates     = coordinates;
 }