public async void RemoveSelectedLocations_ShouldSucceed()
        {
            // Arrange
            SetUp();
            LocationsViewModel sit = null;
            var snapshotsToDelete  = new List <LocationSnapshot>
            {
                new LocationSnapshot {
                    Id = 1
                },
                new LocationSnapshot {
                    Id = 2
                }
            };

            _snapshotDataService.GetSnapshotsByLocationIdAsync(Arg.Any <int>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <IEnumerable <LocationSnapshot> >();
                tcs.SetResult(snapshotsToDelete);
                return(tcs.Task);
            });
            _snapshotDataService.RemoveSnapshotAsync(Arg.Any <int>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <LocationSnapshot>();
                tcs.SetResult(new LocationSnapshot());
                return(tcs.Task);
            });
            _pictureService.RemoveSnapshotContentAsync(Arg.Any <LocationSnapshot>())
            .Returns(_ => Task.CompletedTask);
            _locationDataService.RemoveLocationAsync(Arg.Any <int>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <Location>();
                tcs.SetResult(sit.Locations[1]);
                return(tcs.Task);
            });

            // Act
            sit = CreateViewModel();
            await sit.OnLoaded();

            sit.SelectedLocations = new List <Location> {
                sit.Locations[1]
            };
            await sit.RemoveSelectedLocations();

            // Assert
            Assert.Equal(2, sit.Locations.Count);
            Assert.DoesNotContain(sit.Locations, _ => _.Name == "Prague");
            await _snapshotDataService.Received().RemoveSnapshotAsync(snapshotsToDelete[0].Id);

            await _snapshotDataService.Received().RemoveSnapshotAsync(snapshotsToDelete[1].Id);

            await _pictureService.Received().RemoveSnapshotContentAsync(snapshotsToDelete[0]);

            await _pictureService.Received().RemoveSnapshotContentAsync(snapshotsToDelete[1]);
        }
        public async void ImportAsync_ShouldImportNewLocation()
        {
            // Arrange
            SetUp();
            _locationServiceProxy.GetAllLocationsAsync()
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <IEnumerable <Location> >();
                tcs.SetResult(new List <Location>());
                return(tcs.Task);
            });
            _locationServiceProxy.AddLocationAsync(Arg.Any <Location>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <Location>();
                tcs.SetResult(_locationToImport);
                return(tcs.Task);
            });
            _snapshotServiceProxy.GetSnapshotsByLocationIdAsync(Arg.Any <int>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <IEnumerable <LocationSnapshot> >();
                tcs.SetResult(new List <LocationSnapshot>());
                return(tcs.Task);
            });

            // Act
            var sit = new LocationDataImporter(_dataServiceFactory);
            await sit.ImportAsync(new List <Location> {
                _locationToImport
            }, new CancellationTokenSource().Token);

            // Assert
            await _locationServiceProxy.Received().AddLocationAsync(_locationToImport);

            await _snapshotServiceProxy.Received().AddSnapshotAsync(_snapshotsToImport[0]);

            await _snapshotServiceProxy.Received().AddSnapshotAsync(_snapshotsToImport[1]);

            await _pictureServiceProxy.Received().SaveSnapshotContentAsync(_snapshotsToImport[0], _pictureData);

            await _pictureServiceProxy.Received().SaveSnapshotContentAsync(_snapshotsToImport[1], _pictureData);
        }
        public async void RemoveSelectedSnapshots_ShouldSucceed()
        {
            // Arrange
            SetUp();
            var navParams = new SnapshotsViewNavParams {
                SnapshotsIdsource = new Location()
            };
            var thumbnails = new List <SnapshotThumbnail>
            {
                new SnapshotThumbnail {
                    Snapshot = _snapshots[0]
                },
                new SnapshotThumbnail {
                    Snapshot = _snapshots[1]
                },
                new SnapshotThumbnail {
                    Snapshot = _snapshots[2]
                }
            };
            SnapshotsViewModel sit = null;

            _snapshotDataService.RemoveSnapshotAsync(Arg.Any <int>())
            .Returns(_ =>
            {
                var tcs = new TaskCompletionSource <LocationSnapshot>();
                tcs.SetResult(_snapshots[1]);
                return(tcs.Task);
            });
            _pictureService.RemoveSnapshotContentAsync(Arg.Any <LocationSnapshot>())
            .Returns(_ => Task.CompletedTask);

            // Act
            sit = CreateViewModel();
            sit.NavigationParam = navParams;
            await sit.OnLoaded();

            sit.BeginSelectSnapshot();
            sit.SelectedThumbnails = new List <SnapshotThumbnail> {
                thumbnails[1]
            };
            await sit.RemoveSelectedSnapshots();

            // Assert
            Assert.Equal(2, sit.SnapshotThumbnails.Count);
            Assert.DoesNotContain(sit.SnapshotThumbnails.Select(_ => _.Snapshot), _ => _.PictureFileName == "Barcelona_2.jpg");
            await _snapshotDataService.Received().RemoveSnapshotAsync(_snapshots[1].Id);

            await _pictureService.Received().RemoveSnapshotContentAsync(_snapshots[1]);
        }