Exemple #1
0
        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 void SetUp()
        {
            var idCounter = 0;

            repoList = new List<DriveReport>();
            _emplMock = Substitute.For<IGenericRepository<Employment>>();
            _calculatorMock = Substitute.For<IReimbursementCalculator>();
            _orgUnitMock = Substitute.For<IGenericRepository<OrgUnit>>();
            _routeMock = Substitute.For<IRoute<RouteInformation>>();
            _coordinatesMock = Substitute.For<IAddressCoordinates>();
            _subMock = Substitute.For<IGenericRepository<Core.DomainModel.Substitute>>();
            _mailServiceMock = Substitute.For<IMailService>();
            _reportRepoMock = NSubstitute.Substitute.For<IGenericRepository<DriveReport>>();
            _personMock = Substitute.For<IGenericRepository<Person>>();
            _logger = new Core.ApplicationServices.Logger.Logger();
            _customSettings = new CustomSettings();

            _reportRepoMock.Insert(new DriveReport()).ReturnsForAnyArgs(x => x.Arg<DriveReport>()).AndDoes(x => repoList.Add(x.Arg<DriveReport>())).AndDoes(x => x.Arg<DriveReport>().Id = idCounter).AndDoes(x => idCounter++);
            _reportRepoMock.AsQueryable().ReturnsForAnyArgs(repoList.AsQueryable());

            _calculatorMock.Calculate(new RouteInformation(), new DriveReport()).ReturnsForAnyArgs(x => x.Arg<DriveReport>());

            _coordinatesMock.GetAddressCoordinates(new Address()).ReturnsForAnyArgs(new DriveReportPoint()
            {
                Latitude = "1",
                Longitude = "2",
            });

            _routeMock.GetRoute(DriveReportTransportType.Car, new List<Address>()).ReturnsForAnyArgs(new RouteInformation()
            {
                Length = 2000
            });

            _uut = new DriveReportService(_mailServiceMock, _reportRepoMock, _calculatorMock, _orgUnitMock, _emplMock, _subMock, _coordinatesMock, _routeMock, _rateTypeMock, _personMock, _logger, _customSettings);
        }
Exemple #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>();
 }
Exemple #4
0
 public PersonService(IGenericRepository <PersonalAddress> addressRepo, IRoute <RouteInformation> route, IAddressCoordinates coordinates, ILogger logger)
 {
     _addressRepo = addressRepo;
     _route       = route;
     _coordinates = coordinates;
     _logger      = logger;
 }
 public DriveReportService(IGenericRepository <DriveReport> reportRepo, IReimbursementCalculator calculator, IAddressCoordinates coordinates, IRoute <RouteInformation> route, IGenericRepository <RateType> rateTypeRepo, IMailSender mailSender, IGenericRepository <OrgUnit> orgUnitRepository, IGenericRepository <Employment> employmentRepository, IGenericRepository <Substitute> substituteRepository, ILogger <DriveReportService> logger) : base(mailSender, orgUnitRepository, employmentRepository, substituteRepository, logger, reportRepo)
 {
     _route        = route;
     _rateTypeRepo = rateTypeRepo;
     _coordinates  = coordinates;
     _calculator   = calculator;
 }
        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);
        }
Exemple #7
0
 public PersonService(IGenericRepository <PersonalAddress> addressRepo, IRoute <RouteInformation> route, IAddressCoordinates coordinates, ILogger <PersonService> logger, IKMDAbsenceService absenceService)
 {
     _addressRepo    = addressRepo;
     _route          = route;
     _coordinates    = coordinates;
     _logger         = logger;
     _absenceService = absenceService;
 }
 //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> >();
 }
 public ReportController(IServiceProvider provider)
 {
     driveService       = provider.GetService <IDriveReportService>();
     rateRepo           = provider.GetService <IGenericRepository <Rate> >();
     addressCoordinates = provider.GetService <IAddressCoordinates>();
     driveReportRepo    = provider.GetService <IGenericRepository <DriveReport> >();
     logger             = provider.GetService <ILogger <AuthUserInfoController> >();
     loginRepo          = provider.GetService <IGenericRepository <AppLogin> >();
 }
 public UpdateService(DataProvider provider, IGenericRepository <Employment> employmentRepo, IGenericRepository <AddressHistory> historyRepo, IGenericRepository <PersonalAddress> personalAddressRepo, IGenericRepository <WorkAddress> workAddressRepo, IAddressCoordinates coords)
 {
     _provider            = provider;
     _employmentRepo      = employmentRepo;
     _historyRepo         = historyRepo;
     _personalAddressRepo = personalAddressRepo;
     _workAddressRepo     = workAddressRepo;
     _coords = coords;
 }
        /// <summary>
        /// The calculate.
        /// </summary>
        /// <param name="address1">
        /// The address 1.
        /// </param>
        /// <param name="address2">
        /// The address 2.
        /// </param>
        /// <returns>
        /// The <see cref="decimal"/>.
        /// return distance in kilometers
        /// </returns>
        public double Calculate(IAddressCoordinates address1, IAddressCoordinates address2)
        {
            var arg1    = Math.Pow(Math.Sin((address2.Latitude - address1.Latitude) * 0.5), 2);
            var arg2    = Math.Pow(Math.Sin((address2.Longitude - address1.Longitude) * 0.5), 2);
            var argSqrt = Math.Sqrt(arg1 + (Math.Cos(address2.Latitude) * Math.Cos(address1.Latitude) * arg2));

            var result = 2d * EarthRadius * Math.Asin(argSqrt);

            return(result);
        }
 public PersonService(IGenericRepository <PersonalAddress> personalAddressRepo, IGenericRepository <Address> addressRepo, IGenericRepository <Employment> employmentRepo, IGenericRepository <OrgUnit> orgUnitsRepo, IRoute <RouteInformation> route, IAddressCoordinates coordinates, ILogger <PersonService> logger)
 {
     _personalAddressRepo = personalAddressRepo;
     _addressRepo         = addressRepo;
     _route          = route;
     _coordinates    = coordinates;
     _logger         = logger;
     _employmentRepo = employmentRepo;
     _orgUnitsRepo   = orgUnitsRepo;
 }
 public DriveReportSyncService(IGenericRepository <Core.DmzModel.DriveReport> dmzDriveReportRepo, IGenericRepository <Core.DomainModel.DriveReport> masterDriveReportRepo, IGenericRepository <Core.DomainModel.Rate> rateRepo, IGenericRepository <LicensePlate> licensePlateRepo, IDriveReportService driveService, IRoute <RouteInformation> routeService, IAddressCoordinates coordinates, IGenericRepository <Core.DomainModel.Employment> emplRepo, ILogger logger)
 {
     _dmzDriveReportRepo    = dmzDriveReportRepo;
     _masterDriveReportRepo = masterDriveReportRepo;
     _rateRepo         = rateRepo;
     _licensePlateRepo = licensePlateRepo;
     _driveService     = driveService;
     _routeService     = routeService;
     _coordinates      = coordinates;
     _emplRepo         = emplRepo;
     _logger           = logger;
 }
Exemple #14
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> >();
            _mailServiceMock         = NSubstitute.Substitute.For <IMailService>();

            _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 <DriveReport> >();
            _driveService = NSubstitute.Substitute.For <IDriveReportService>();
            _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, _mailServiceMock, NSubstitute.Substitute.For <IAddressHistoryService>(), _reportRepo, _driveService, _subservice, _subRepo);
        }
        public void SetUp()
        {
            var idCounter = 0;

            repoList         = new List <DriveReport>();
            _emplMock        = Substitute.For <IGenericRepository <Employment> >();
            _calculatorMock  = Substitute.For <IReimbursementCalculator>();
            _orgUnitMock     = Substitute.For <IGenericRepository <OrgUnit> >();
            _rateTypeMock    = Substitute.For <IGenericRepository <RateType> >();
            _routeMock       = Substitute.For <IRoute <RouteInformation> >();
            _coordinatesMock = Substitute.For <IAddressCoordinates>();
            _subMock         = Substitute.For <IGenericRepository <Core.DomainModel.Substitute> >();
            _mailServiceMock = Substitute.For <IMailService>();
            _subServiceMock  = Substitute.For <ISubstituteService>();
            _reportRepoMock  = NSubstitute.Substitute.For <IGenericRepository <DriveReport> >();
            _personMock      = Substitute.For <IGenericRepository <Person> >();
            _logger          = new Core.ApplicationServices.Logger.Logger();
            _customSettings  = new CustomSettings();

            _reportRepoMock.Insert(new DriveReport()).ReturnsForAnyArgs(x => x.Arg <DriveReport>()).AndDoes(x => repoList.Add(x.Arg <DriveReport>())).AndDoes(x => x.Arg <DriveReport>().Id = idCounter).AndDoes(x => idCounter++);
            _reportRepoMock.AsQueryable().ReturnsForAnyArgs(repoList.AsQueryable());

            _calculatorMock.Calculate(new RouteInformation(), new DriveReport()).ReturnsForAnyArgs(x => x.Arg <DriveReport>());
            // The mocked reports share the exact same timestamp if they are driven on same day, so for test purposes we simplify the method and check if they are identical, so we are able to mock the method.
            _calculatorMock.AreReportsDrivenOnSameDay(1, 1).ReturnsForAnyArgs(x => (long)x[0] == (long)x[1]);

            _rateTypeMock.AsQueryable().ReturnsForAnyArgs(new List <RateType>
            {
                new RateType()
                {
                    TFCode = "1234",
                    IsBike = false,
                    RequiresLicensePlate = true,
                    Id          = 1,
                    Description = "TestRate"
                }
            }.AsQueryable());

            _coordinatesMock.GetAddressCoordinates(new Address()).ReturnsForAnyArgs(new DriveReportPoint()
            {
                Latitude  = "1",
                Longitude = "2",
            });

            _routeMock.GetRoute(DriveReportTransportType.Car, new List <Address>()).ReturnsForAnyArgs(new RouteInformation()
            {
                Length = 2000
            });

            _uut = new DriveReportService(_mailServiceMock, _reportRepoMock, _calculatorMock, _orgUnitMock, _emplMock, _subMock, _coordinatesMock, _routeMock, _rateTypeMock, _personMock, _logger, _customSettings);
        }
Exemple #16
0
 public DriveReportService(IMailSender mailSender, IGenericRepository <DriveReport> driveReportRepository, IReimbursementCalculator calculator, IGenericRepository <OrgUnit> orgUnitRepository, IGenericRepository <Employment> employmentRepository, IGenericRepository <Substitute> substituteRepository, IAddressCoordinates coordinates, IRoute <RouteInformation> route, IGenericRepository <RateType> rateTypeRepo, IGenericRepository <Person> personRepo, ILogger logger)
 {
     _route                 = route;
     _rateTypeRepo          = rateTypeRepo;
     _coordinates           = coordinates;
     _calculator            = calculator;
     _orgUnitRepository     = orgUnitRepository;
     _employmentRepository  = employmentRepository;
     _substituteRepository  = substituteRepository;
     _mailSender            = mailSender;
     _driveReportRepository = driveReportRepository;
     _personRepository      = personRepo;
     _logger                = logger;
 }
        public void SetUp()
        {
            var idCounter = 0;

            repoList         = new List <DriveReport>();
            _emplMock        = Substitute.For <IGenericRepository <Employment> >();
            _calculatorMock  = Substitute.For <IReimbursementCalculator>();
            _orgUnitMock     = Substitute.For <IGenericRepository <OrgUnit> >();
            _rateTypeMock    = Substitute.For <IGenericRepository <RateType> >();
            _routeMock       = Substitute.For <IRoute <RouteInformation> >();
            _coordinatesMock = Substitute.For <IAddressCoordinates>();
            _subMock         = Substitute.For <IGenericRepository <Core.DomainModel.Substitute> >();
            _mailMock        = Substitute.For <IMailSender>();
            _reportRepoMock  = NSubstitute.Substitute.For <IGenericRepository <DriveReport> >();
            _loggerMock      = NSubstitute.Substitute.For <ILogger>();

            _reportRepoMock.Insert(new DriveReport()).ReturnsForAnyArgs(x => x.Arg <DriveReport>()).AndDoes(x => repoList.Add(x.Arg <DriveReport>())).AndDoes(x => x.Arg <DriveReport>().Id = idCounter).AndDoes(x => idCounter++);
            _reportRepoMock.AsQueryable().ReturnsForAnyArgs(repoList.AsQueryable());

            _calculatorMock.Calculate(new RouteInformation(), new DriveReport()).ReturnsForAnyArgs(x => x.Arg <DriveReport>());

            _rateTypeMock.AsQueryable().ReturnsForAnyArgs(new List <RateType>
            {
                new RateType()
                {
                    TFCode = "1234",
                    IsBike = false,
                    RequiresLicensePlate = true,
                    Id          = 1,
                    Description = "TestRate"
                }
            }.AsQueryable());

            _coordinatesMock.GetAddressCoordinates(new Address()).ReturnsForAnyArgs(new DriveReportPoint()
            {
                Latitude  = "1",
                Longitude = "2",
            });

            _routeMock.GetRoute(DriveReportTransportType.Car, new List <Address>()).ReturnsForAnyArgs(new RouteInformation()
            {
                Length = 2000
            });

            _uut = new DriveReportService(_reportRepoMock, _calculatorMock, _coordinatesMock, _routeMock, _rateTypeMock, _mailMock, _orgUnitMock, _emplMock, _subMock, _loggerMock);
        }
        public void SetUp()
        {
            _persons = new List <Person> {
                new Person
                {
                    Id        = 1,
                    FirstName = "Morten",
                    LastName  = "Rasmussen",
                    CprNumber = "1234567890",
                    Initials  = "MR"
                },
                new Person
                {
                    Id        = 2,
                    FirstName = "Morten",
                    LastName  = "Jørgensen",
                    CprNumber = "0987654321",
                    Initials  = "MJ"
                },
                new Person
                {
                    Id        = 3,
                    FirstName = "Jacob",
                    LastName  = "Jensen",
                    CprNumber = "456456456",
                    Initials  = "JOJ"
                }
            }.AsQueryable();

            _routeMock = NSubstitute.Substitute.For <IRoute <RouteInformation> >();
            _routeMock.GetRoute(DriveReportTransportType.Car, new List <Address>()).ReturnsForAnyArgs(new RouteInformation());
            _addressRepoMock = NSubstitute.Substitute.For <IGenericRepository <PersonalAddress> >();
            _coordinatesMock = NSubstitute.Substitute.For <IAddressCoordinates>();
            _loggerMock      = NSubstitute.Substitute.For <ILogger>();
            _absenceService  = NSubstitute.Substitute.For <IKMDAbsenceService>();

            _coordinatesMock.GetAddressCoordinates(new Address()).ReturnsForAnyArgs(new Address
            {
                Latitude  = "1",
                Longitude = "1"
            });
            _uut = new Core.ApplicationServices.PersonService(_addressRepoMock, _routeMock, _coordinatesMock, _loggerMock, _absenceService);
        }
        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);
        }
Exemple #20
0
        public void SetUp()
        {
            _idCounter = 0;
            var routeList = new List <PersonalRoute>();

            _coordinatesMock = NSubstitute.Substitute.For <IAddressCoordinates>();
            _coordinatesMock.GetAddressCoordinates(new Address()).ReturnsForAnyArgs(new Point
            {
                Latitude  = "1",
                Longitude = "1"
            });


            _routeRepoMock = NSubstitute.Substitute.For <IGenericRepository <PersonalRoute> >();
            _routeRepoMock.Insert(new PersonalRoute()).ReturnsForAnyArgs(x => x.Arg <PersonalRoute>()).AndDoes(x => routeList.Add(x.Arg <PersonalRoute>())).AndDoes(x => x.Arg <PersonalRoute>().Id = _idCounter).AndDoes(x => _idCounter++);
            _routeRepoMock.AsQueryable().ReturnsForAnyArgs(routeList.AsQueryable());

            _uut        = new PersonalRouteService(_coordinatesMock, _routeRepoMock);
            _testPerson = new Person
            {
                Id = 1
            };
        }
        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>();
            _mailServiceMock         = NSubstitute.Substitute.For <IMailService>();

            _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 <DriveReport> >();
            _driveService = NSubstitute.Substitute.For <IDriveReportService>();
            _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, _mailServiceMock, NSubstitute.Substitute.For <IAddressHistoryService>(), _reportRepo, _driveService, _subservice, _subRepo);
        }
 public BestRoute(IAddressCoordinates addressCoordinates, IRouter router)
 {
     _addressCoordinates = addressCoordinates;
     _router             = router;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="coordinates"></param>
 public CoordinateController(IAddressCoordinates coordinates, ILogger <CoordinateController> logger)
 {
     _coordinates = coordinates;
     _logger      = logger;
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="coordinates"></param>
 public CoordinateController(IAddressCoordinates coordinates, ILogger log)
 {
     _coordinates = coordinates;
     _logger      = log;
 }
        public void SetUp()
        {
            _persons = new List <Person> {
                new Person
                {
                    Id        = 1,
                    FirstName = "Morten",
                    LastName  = "Rasmussen",
                    CprNumber = "1234567890",
                    Initials  = "MR"
                },
                new Person
                {
                    Id        = 2,
                    FirstName = "Morten",
                    LastName  = "Jørgensen",
                    CprNumber = "0987654321",
                    Initials  = "MJ"
                },
                new Person
                {
                    Id        = 3,
                    FirstName = "Jacob",
                    LastName  = "Jensen",
                    CprNumber = "456456456",
                    Initials  = "JOJ"
                }
            }.AsQueryable();

            _routeMock = NSubstitute.Substitute.For <IRoute <RouteInformation> >();
            _routeMock.GetRoute(DriveReportTransportType.Car, new List <Address>()).ReturnsForAnyArgs(new RouteInformation());
            _personalAddressRepoMock = NSubstitute.Substitute.For <IGenericRepository <PersonalAddress> >();
            _addressRepoMock         = NSubstitute.Substitute.For <IGenericRepository <Address> >();
            _employmentsRepoMock     = NSubstitute.Substitute.For <IGenericRepository <Employment> >();
            _orgUnitsRepoMock        = NSubstitute.Substitute.For <IGenericRepository <OrgUnit> >();

            _orgUnitsRepoMock.AsQueryable().ReturnsForAnyArgs(new List <OrgUnit>
            {
                new OrgUnit
                {
                    Id               = 1,
                    OrgId            = 1,
                    ShortDescription = "orgUnit1",
                    LongDescription  = "OrgUnit 1.0",
                    Level            = 1,
                    ParentId         = null
                },
                new OrgUnit
                {
                    Id               = 2,
                    OrgId            = 2,
                    ShortDescription = "orgUnit2",
                    LongDescription  = "OrgUnit 2.1",
                    Level            = 2,
                    ParentId         = 1
                },
                new OrgUnit
                {
                    Id               = 3,
                    OrgId            = 3,
                    ShortDescription = "orgUnit3",
                    LongDescription  = "OrgUnit 2.2",
                    Level            = 2,
                    ParentId         = 1
                }
            }.AsQueryable());

            _loggerMock      = NSubstitute.Substitute.For <ILogger>();
            _coordinatesMock = NSubstitute.Substitute.For <IAddressCoordinates>();
            _coordinatesMock.GetAddressCoordinates(new Address()).ReturnsForAnyArgs(new Address
            {
                Latitude  = "1",
                Longitude = "1"
            });
            _uut = new Core.ApplicationServices.PersonService(_personalAddressRepoMock, _addressRepoMock, _employmentsRepoMock, _orgUnitsRepoMock, _routeMock, _coordinatesMock, _loggerMock);
        }
        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,
            });
        }
Exemple #27
0
        public void SetUp()
        {
            _emplRepo               = NSubstitute.Substitute.For <IGenericRepository <Employment> >();
            _logger                 = NSubstitute.Substitute.For <ILogger>();
            _dmzRepoMock            = NSubstitute.Substitute.For <IGenericRepository <Core.DmzModel.DriveReport> >();
            _coordinatesMock        = NSubstitute.Substitute.For <IAddressCoordinates>();
            _masterRepoMock         = NSubstitute.Substitute.For <IGenericRepository <Core.DomainModel.DriveReport> >();
            _driveReportServiceMock = NSubstitute.Substitute.For <IDriveReportService>();
            _rateRepoMock           = NSubstitute.Substitute.For <IGenericRepository <Rate> >();
            _licensePlateRepoMock   = NSubstitute.Substitute.For <IGenericRepository <LicensePlate> >();
            _routeMock              = NSubstitute.Substitute.For <IRoute <RouteInformation> >();
            _routeMock.GetRoute(DriveReportTransportType.Car, new List <Address>()).ReturnsForAnyArgs(new RouteInformation()
            {
                GeoPoints = "geogeo"
            });

            _coordinatesMock.GetAddressFromCoordinates(new Address()).ReturnsForAnyArgs(new Address()
            {
                Latitude     = "1",
                Longitude    = "1",
                StreetName   = "Katrinebjergvej",
                StreetNumber = "93B",
                ZipCode      = 8200,
                Town         = "Aarhus N"
            });

            _dmzRepoMock.WhenForAnyArgs(x => x.Delete(new Core.DmzModel.DriveReport())).Do(p => _dmzReportList.Remove(p.Arg <Core.DmzModel.DriveReport>()));


            _driveReportServiceMock.WhenForAnyArgs(x => x.Create(new Core.DomainModel.DriveReport())).Do(rep => _masterReportList.Add(rep.Arg <Core.DomainModel.DriveReport>()));
            _dmzRepoMock.WhenForAnyArgs(x => x.Insert(new Core.DmzModel.DriveReport())).Do(t => _dmzReportList.Add(t.Arg <Core.DmzModel.DriveReport>()));

            _rateRepoMock.AsQueryable().ReturnsForAnyArgs(new List <Rate>()
            {
                new Rate()
                {
                    Id     = 1,
                    KmRate = 12,
                    Active = true,
                    Year   = 2015,
                    Type   = new RateType()
                    {
                        Id = 1,
                        RequiresLicensePlate = true,
                        TFCode      = "1234",
                        Description = "TestDescription"
                    }
                }
            }.AsQueryable());

            _licensePlateRepoMock.AsQueryable().ReturnsForAnyArgs(new List <LicensePlate>()
            {
                new LicensePlate()
                {
                    Id          = 1,
                    PersonId    = 1,
                    Plate       = "TestPlate",
                    IsPrimary   = true,
                    Description = "TestDesc",
                }
            }.AsQueryable());

            _dmzReportList = new List <DriveReport>()
            {
                new DriveReport()
                {
                    Id                = 1,
                    Purpose           = "Test",
                    StartsAtHome      = false,
                    EndsAtHome        = false,
                    ManualEntryRemark = "ManualEntry",
                    Date              = "2015-05-27",
                    EmploymentId      = 1,
                    ProfileId         = 1,
                    RateId            = 1,
                    Profile           = new Profile()
                    {
                        FullName = "Test Testesen [TT]"
                    },
                    Route = new Route()
                    {
                        Id             = 1,
                        GPSCoordinates = new List <GPSCoordinate>()
                        {
                            new GPSCoordinate()
                            {
                                Latitude  = StringCipher.Encrypt("1", Encryptor.EncryptKey),
                                Longitude = StringCipher.Encrypt("1", Encryptor.EncryptKey),
                            },
                            new GPSCoordinate()
                            {
                                Latitude  = StringCipher.Encrypt("2", Encryptor.EncryptKey),
                                Longitude = StringCipher.Encrypt("2", Encryptor.EncryptKey),
                            }
                        }
                    }
                },
                new DriveReport()
                {
                    Id                = 2,
                    Purpose           = "Test2",
                    StartsAtHome      = true,
                    EndsAtHome        = true,
                    ManualEntryRemark = "ManualEntry",
                    Date              = "2015-05-26",
                    EmploymentId      = 1,
                    ProfileId         = 1,
                    RateId            = 1,
                    Profile           = new Profile()
                    {
                        FullName = "Test Testesen [TT]"
                    },
                    Route = new Route()
                    {
                        Id             = 2,
                        GPSCoordinates = new List <GPSCoordinate>()
                        {
                            new GPSCoordinate()
                            {
                                Latitude  = StringCipher.Encrypt("1", Encryptor.EncryptKey),
                                Longitude = StringCipher.Encrypt("1", Encryptor.EncryptKey),
                            },
                            new GPSCoordinate()
                            {
                                Latitude  = StringCipher.Encrypt("2", Encryptor.EncryptKey),
                                Longitude = StringCipher.Encrypt("2", Encryptor.EncryptKey),
                            }
                        }
                    }
                }
            };

            _masterRepoMock.AsQueryable().ReturnsForAnyArgs(_masterReportList.AsQueryable());
            _dmzRepoMock.AsQueryable().ReturnsForAnyArgs(_dmzReportList.AsQueryable());

            _uut = new DriveReportSyncService(_dmzRepoMock, _masterRepoMock, _rateRepoMock, _licensePlateRepoMock, _driveReportServiceMock, _routeMock, _coordinatesMock, _emplRepo, _logger);
        }
 public CachedAddressLaunderer(IGenericRepository <CachedAddress> repo, IAddressLaunderer actualLaunderer, IAddressCoordinates coordinates)
 {
     _repo            = repo;
     _actualLaunderer = actualLaunderer;
     _coordinates     = coordinates;
 }
Exemple #29
0
 public PersonalRouteService(IAddressCoordinates coordinates, IGenericRepository <PersonalRoute> routeRepo)
 {
     _coordinates = coordinates;
     _routeRepo   = routeRepo;
 }
Exemple #30
0
 //GET: odata/PersonalAddresses
 public PersonalAddressesController(IServiceProvider provider) : base(provider)
 {
     coordinates = provider.GetService <IAddressCoordinates>();
     logger      = provider.GetService <ILogger <PersonalAddressesController> >();
 }