Exemplo n.º 1
0
        public void TripSmartBuilder_GetPhotoLocations_OK()
        {
            using (
                var streamWriter =
                    new StreamWriter(File.Open(@"c:\TripLine\PhotoLocations.txt", FileMode.Create,
                                               FileAccess.Write)))
            {
                DisplayPhotoLocations(streamWriter, "In collection (by position)", _photoStore.GetPhotos(), true, false);
                DisplayPhotoLocations(streamWriter, "In collection (by adddress)", _photoStore.GetPhotos(), false, true);
            }

            using (
                var streamWriter =
                    new StreamWriter(File.Open(@"c:\TripLine\NewPhotoLocations.txt", FileMode.Create, FileAccess.Write)))
            {
                var photos = _photoStore.PeakForNewPhotos();


                DisplayPhotoLocations(streamWriter, "New travel photos (found by position)", photos, true, false);


                DisplayPhotoLocations(streamWriter, "New travel photos (found by address)", photos, false, true);


                DisplayPhotoLocations(streamWriter, "New none travel photos", _photoStore.NewImportPhotos.Where(p => !p.IsTravel).ToList(), true, true);
            }
        }
Exemplo n.º 2
0
        public async Task GetPhotosReturnsMultipleProfilePhotoIdsTest()
        {
            var profileId = Guid.NewGuid();
            var expected  = new List <Guid>();

            var sut = new PhotoStore(Config.Storage);

            for (int index = 0; index < 10; index++)
            {
                var photo     = Model.Ignoring <Photo>(x => x.Data).Create <Photo>().Set(x => x.ProfileId = profileId).Set(x => x.ContentType = ".jpg");
                var photoData = Model.Create <byte[]>();

                using (var inputStream = new MemoryStream(photoData))
                {
                    photo.Data = inputStream;

                    var photoDetails = await sut.StorePhoto(photo, CancellationToken.None).ConfigureAwait(false);

                    expected.Add(photoDetails.Id);
                }
            }

            var actual = await sut.GetPhotos(profileId, CancellationToken.None).ConfigureAwait(false);

            actual.Should().BeEquivalentTo(expected);
        }
Exemplo n.º 3
0
        private async Task IsDeleted(Guid profileId, IIdentity identity)
        {
            var accountReference = new Account(identity.Name);
            var storageAccount   = CloudStorageAccount.Parse(Config.AzureConnectionString);
            var operation        = TableOperation.Retrieve <AccountAdapter>(accountReference.Provider, accountReference.Subject);

            var client = storageAccount.CreateCloudTableClient();
            var table  = client.GetTableReference("Accounts");

            var accountResult = await table.ExecuteAsync(operation).ConfigureAwait(false);

            accountResult.HttpStatusCode.Should().Be(404);

            var profileStore = new ProfileStore(Config.Storage);

            var storedProfile = await profileStore.GetProfile(profileId, CancellationToken.None).ConfigureAwait(false);

            storedProfile.Should().BeNull();

            var photoStore = new PhotoStore(Config.Storage);

            var storedPhotos = await photoStore.GetPhotos(profileId, CancellationToken.None).ConfigureAwait(false);

            storedPhotos.Should().BeEmpty();
        }
Exemplo n.º 4
0
        public void GetPhotosThrowsExceptionWithEmptyProfileIdTest()
        {
            var sut = new PhotoStore(Config.Storage);

            Func <Task> action = async() =>
                                 await sut.GetPhotos(Guid.Empty, CancellationToken.None).ConfigureAwait(false);

            action.Should().Throw <ArgumentException>();
        }
Exemplo n.º 5
0
        public async Task GetPhotosReturnsSingleProfilePhotoIdTest()
        {
            var photo     = Model.Ignoring <Photo>(x => x.Data).Create <Photo>().Set(x => x.ContentType = ".jpg");
            var photoData = Model.Create <byte[]>();

            var sut = new PhotoStore(Config.Storage);

            using (var inputStream = new MemoryStream(photoData))
            {
                photo.Data = inputStream;

                var photoDetails = await sut.StorePhoto(photo, CancellationToken.None).ConfigureAwait(false);

                var photos = (await sut.GetPhotos(photo.ProfileId, CancellationToken.None).ConfigureAwait(false)).ToList();

                photos.Count.Should().Be(1);
                photos[0].Should().Be(photoDetails.Id);
            }
        }
Exemplo n.º 6
0
        public async Task GetPhotosReturnsEmptyWhenProfileNotFoundTest()
        {
            // Retrieve storage account from connection-string
            var storageAccount = CloudStorageAccount.Parse(Config.Storage.ConnectionString);

            // Create the client
            var client = storageAccount.CreateCloudBlobClient();

            var container = client.GetContainerReference("photos");

            await container.CreateIfNotExistsAsync().ConfigureAwait(false);

            var sut = new PhotoStore(Config.Storage);

            var actual = await sut.GetPhotos(Guid.NewGuid(), CancellationToken.None)
                         .ConfigureAwait(false);

            actual.Should().BeEmpty();
        }