Example #1
0
 public LocationDataImporter(IDataServiceFactory dataServiceFactory)
 {
     _locationServiceProxy = dataServiceFactory.CreateLocationDataService(DataSourceType.Remote);
     _snapshotServiceProxy = dataServiceFactory.CreateLocationSnapshotDataService(DataSourceType.Remote);
     _snapshotService      = dataServiceFactory.CreateLocationSnapshotDataService(DataSourceType.Local);
     _pictureServiceProxy  = dataServiceFactory.CreatePictureService(DataSourceType.Remote);
     _pictureService       = dataServiceFactory.CreatePictureService(DataSourceType.Local);
 }
        private void SetUp()
        {
            _locations = new List <Location>
            {
                new Location {
                    Id = 1, Name = "Barcelona"
                },
                new Location {
                    Id = 2, Name = "Prague"
                },
                new Location {
                    Id = 3, Name = "Frankfurt"
                }
            };
            _snapshotGroups = new List <SnapshotGroup>
            {
                new SnapshotGroup {
                    Name = "December 2018"
                },
                new SnapshotGroup {
                    Name = "March 2019"
                }
            };
            Task <IEnumerable <SnapshotGroup> > dataFetchOperation()
            {
                var tcs = new TaskCompletionSource <IEnumerable <SnapshotGroup> >();

                tcs.SetResult(_snapshotGroups);
                return(tcs.Task);
            };
            _snapshotDataService = Substitute.For <ILocationSnapshotDataService>();
            _snapshotDataService.ChooseGroupByOperation(Arg.Any <GroupByCriteria>())
            .Returns(dataFetchOperation);
            _locationDataService = Substitute.For <ILocationDataService>();
            _locationDataService.GetAllLocationsAsync()
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <IEnumerable <Location> >();
                tcs.SetResult(_locations);
                return(tcs.Task);
            });
            _dialogService = Substitute.For <IDialogService>();
            _dialogService.ShowConfirmationAsync(Arg.Any <string>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <ConfirmationAnswer>();
                tcs.SetResult(ConfirmationAnswer.OK);
                return(tcs.Task);
            });
            _pictureService          = Substitute.For <IPictureService>();
            _locationDataImporter    = Substitute.For <ILocationDataImporter>();
            _dataSourceGovernor      = Substitute.For <IDataSourceGovernor>();
            _connectivityService     = Substitute.For <IConnectivityService>();
            _navigationService       = Substitute.For <INavigationService>();
            _platformSpecificActions = Substitute.For <IPlatformSpecificActions>();
        }
 private void SetUp()
 {
     _navigationService           = Substitute.For <INavigationService>();
     _cameraService               = Substitute.For <ICameraService>();
     _bitmapConverter             = Substitute.For <IBitmapConverter>();
     _pictureService              = Substitute.For <IPictureService>();
     _locationSnapshotDataService = Substitute.For <ILocationSnapshotDataService>();
     _locationService             = Substitute.For <ILocationService>();
     _eventAggregator             = new EventAggregator();
 }
Example #4
0
 public SnapshotPicturesController(IHostingEnvironment hostingEnvironment,
                                   IFileSystemService fileSystemService,
                                   IImageService imageService,
                                   ILocationSnapshotDataService locationSnapshotDataService,
                                   ILogger <SnapshotPicturesController> logger)
 {
     _hostingEnvironment          = hostingEnvironment;
     _fileSystemService           = fileSystemService;
     _imageService                = imageService;
     _locationSnapshotDataService = locationSnapshotDataService;
     _logger = logger;
 }
        private void SetUp()
        {
            _dataServiceFactory   = Substitute.For <IDataServiceFactory>();
            _locationServiceProxy = Substitute.For <ILocationDataService>();
            _snapshotServiceProxy = Substitute.For <ILocationSnapshotDataService>();
            _snapshotService      = Substitute.For <ILocationSnapshotDataService>();
            _pictureServiceProxy  = Substitute.For <IPictureService>();
            _pictureService       = Substitute.For <IPictureService>();

            _dataServiceFactory.CreateLocationDataService(DataSourceType.Remote).Returns(_locationServiceProxy);
            _dataServiceFactory.CreateLocationSnapshotDataService(DataSourceType.Remote).Returns(_snapshotServiceProxy);
            _dataServiceFactory.CreateLocationSnapshotDataService(DataSourceType.Local).Returns(_snapshotService);
            _dataServiceFactory.CreatePictureService(DataSourceType.Remote).Returns(_pictureServiceProxy);
            _dataServiceFactory.CreatePictureService(DataSourceType.Local).Returns(_pictureService);

            _locationToImport = new Location
            {
                Id   = 1,
                Name = "Barcelona"
            };
            _snapshotsToImport = new List <LocationSnapshot>
            {
                new LocationSnapshot
                {
                    Id              = 1,
                    LocationId      = 1,
                    PictureFileName = "Barcelona1.jpg"
                },
                new LocationSnapshot
                {
                    Id              = 2,
                    LocationId      = 1,
                    PictureFileName = "Barcelona2.jpg"
                },
            };

            _snapshotService.GetSnapshotsByLocationIdAsync(Arg.Any <int>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <IEnumerable <LocationSnapshot> >();
                tcs.SetResult(_snapshotsToImport);
                return(tcs.Task);
            });

            _pictureData = new byte[] { 1, 2, 3, 4 };
            _pictureService.GetSnapshotContentAsync(Arg.Any <LocationSnapshot>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <byte[]>();
                tcs.SetResult(_pictureData);
                return(tcs.Task);
            });
        }
Example #6
0
 public CameraViewModel(INavigationService navigationService,
                        ICameraService cameraService,
                        IBitmapConverter bitmapConverter,
                        IPictureService pictureService,
                        ILocationSnapshotDataService locationSnapshotDataService,
                        ILocationService locationService,
                        IEventAggregator eventAggregator)
 {
     _navigationService           = navigationService;
     _cameraService               = cameraService;
     _bitmapConverter             = bitmapConverter;
     _pictureService              = pictureService;
     _locationSnapshotDataService = locationSnapshotDataService;
     _locationService             = locationService;
     _eventAggregator             = eventAggregator;
 }
 private void SetUp()
 {
     _snapshots = new List <LocationSnapshot>
     {
         new LocationSnapshot {
             PictureFileName = "Barcelona1.jpg"
         },
         new LocationSnapshot {
             PictureFileName = "Prague1.jpg"
         },
         new LocationSnapshot {
             PictureFileName = "Frankfurt1.jpg"
         }
     };
     _miniatureData       = new byte[] { 255, 216, 255 };
     _pictureData         = new byte[] { 224, 0, 16 };
     _snapshotDataService = Substitute.For <ILocationSnapshotDataService>();
     _snapshotDataService.GetSnapshotsByIdsAsync(Arg.Any <IEnumerable <int> >())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <IEnumerable <LocationSnapshot> >();
         tcs.SetResult(_snapshots);
         return(tcs.Task);
     });
     _fileSystemService = Substitute.For <IFileSystemService>();
     _fileSystemService.FileExisits(Arg.Any <string>())
     .Returns(true);
     _fileSystemService.ReadAllBytesAsync(Arg.Any <string>())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <byte[]>();
         tcs.SetResult(_pictureData);
         return(tcs.Task);
     });
     _imageService = Substitute.For <IImageService>();
     _imageService.GetThumbnailAsync(Arg.Any <string>())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <byte[]>();
         tcs.SetResult(_miniatureData);
         return(tcs.Task);
     });
 }
        public SnapshotsViewModel(ILocationSnapshotDataService locationSnapshotDataService,
                                  INavigationService navigationService,
                                  IPictureService pictureService,
                                  IBitmapConverter bitmapConverter,
                                  IDialogService dialogService,
                                  IPlatformSpecificActions platformSpecificActions)
        {
            _locationSnapshotDataService = locationSnapshotDataService;
            _navigationService           = navigationService;
            _pictureService          = pictureService;
            _bitmapConverter         = bitmapConverter;
            _dialogService           = dialogService;
            _platformSpecificActions = platformSpecificActions;

            SnapshotThumbnails = new ObservableCollection <SnapshotThumbnail>();
            SelectedThumbnails = new List <SnapshotThumbnail>();
            SelectionMode      = SelectionMode.None;
            IsItemClickEnabled = true;
        }
Example #9
0
        public LocationsViewModel(ILocationDataService locationDataService,
                                  ILocationSnapshotDataService locationSnapshotDataService,
                                  INavigationService navigationService,
                                  IDialogService dialogService,
                                  IPictureService pictureService,
                                  ILocationDataImporter locationDataImporter,
                                  IDataSourceGovernor dataSourceGovernor,
                                  IConnectivityService connectivityService,
                                  IPlatformSpecificActions platformSpecificActions)
        {
            _locationDataService         = locationDataService;
            _locationSnapshotDataService = locationSnapshotDataService;
            _navigationService           = navigationService;
            _dialogService           = dialogService;
            _pictureService          = pictureService;
            _locationDataImporter    = locationDataImporter;
            _dataSourceGovernor      = dataSourceGovernor;
            _connectivityService     = connectivityService;
            _platformSpecificActions = platformSpecificActions;

            GroupByOptions = new List <GroupByCriteria>
            {
                GroupByCriteria.None,
                GroupByCriteria.CreatedDate,
                GroupByCriteria.Longitude,
                GroupByCriteria.Latitude,
                GroupByCriteria.Altitude
            };
            SelectedLocations  = new List <Location>();
            GroupBy            = GroupByCriteria.None;
            SelectionMode      = SelectionMode.None;
            IsItemClickEnabled = true;
            IsInBrowseMode     = true;
            IsInEditMode       = false;
            IsInSelectMode     = false;
        }
Example #10
0
 public LocationSnapshotsController(ILocationSnapshotDataService locationSnapshotDataService,
                                    ILogger <LocationSnapshotsController> logger)
 {
     _locationSnapshotDataService = locationSnapshotDataService;
     _logger = logger;
 }
 private void SetUp()
 {
     _snapshots = new List <LocationSnapshot>
     {
         new LocationSnapshot {
             Id = 1, PictureFileName = "Barcelona_1.jpg"
         },
         new LocationSnapshot {
             Id = 2, PictureFileName = "Barcelona_2.jpg"
         },
         new LocationSnapshot {
             Id = 3, PictureFileName = "Barcelona_3.jpg"
         }
     };
     _miniatures = new List <SnapshotMiniature>
     {
         new SnapshotMiniature {
             Snapshot = _snapshots[0]
         },
         new SnapshotMiniature {
             Snapshot = _snapshots[1]
         },
         new SnapshotMiniature {
             Snapshot = _snapshots[2]
         }
     };
     _thumbnail           = new object();
     _snapshotDataService = Substitute.For <ILocationSnapshotDataService>();
     _snapshotDataService.GetSnapshotsByLocationIdAsync(Arg.Any <int>())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <IEnumerable <LocationSnapshot> >();
         tcs.SetResult(_snapshots);
         return(tcs.Task);
     });
     _snapshotDataService.GetSnapshotsByIdsAsync(Arg.Any <IEnumerable <int> >())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <IEnumerable <LocationSnapshot> >();
         tcs.SetResult(_snapshots);
         return(tcs.Task);
     });
     _pictureService = Substitute.For <IPictureService>();
     _pictureService.GetSnapshotMiniaturesAsync(Arg.Any <IEnumerable <LocationSnapshot> >())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <IEnumerable <SnapshotMiniature> >();
         tcs.SetResult(_miniatures);
         return(tcs.Task);
     });
     _bitmapConverter = Substitute.For <IBitmapConverter>();
     _bitmapConverter.GetBitmapAsync(Arg.Any <byte[]>())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <object>();
         tcs.SetResult(_thumbnail);
         return(tcs.Task);
     });
     _dialogService = Substitute.For <IDialogService>();
     _dialogService.ShowConfirmationAsync(Arg.Any <string>())
     .Returns(_ =>
     {
         var tcs = new TaskCompletionSource <ConfirmationAnswer>();
         tcs.SetResult(ConfirmationAnswer.OK);
         return(tcs.Task);
     });
     _navigationService       = Substitute.For <INavigationService>();
     _platformSpecificActions = Substitute.For <IPlatformSpecificActions>();
 }