public async Task WillUpdateExistingRecord()
        {
            await CloudTableHelper.AddToCloudTableEntities(_cloudTable, CloudTableHelper.TableEntityPodCast);

            var existingRecord = await _sut.Get(CloudTableHelper.TableEntityPodCast.PartitionKey,
                                                CloudTableHelper.TableEntityPodCast.RowKey);

            existingRecord.EpisodePosition = 1000;

            await _sut.Save(existingRecord);

            var list = await CloudTableHelper.GetAllCloudTableEntities(_cloudTable);

            Assert.Single(list);
            Assert.Equal(1000, list.First().EpisodePosition);
        }
        public async Task WillThrowExceptionIfRecordHasChanged()
        {
            await CloudTableHelper.AddToCloudTableEntities(_cloudTable, CloudTableHelper.TableEntityPodCast);

            var v1 = await _sut.Get(CloudTableHelper.TableEntityPodCast.PartitionKey,
                                    CloudTableHelper.TableEntityPodCast.RowKey);

            var v2 = await _sut.Get(CloudTableHelper.TableEntityPodCast.PartitionKey,
                                    CloudTableHelper.TableEntityPodCast.RowKey);

            v1.EpisodePosition = 1000;
            v2.EpisodePosition = 1001;

            await _sut.Save(v2);

            await Assert.ThrowsAsync <StorageException>(() => _sut.Save(v1));
        }
Esempio n. 3
0
        public async Task UpdatesAnEntryInTheTable_IfAlreadyExists()
        {
            await CloudTableHelper.AddToCloudTableEntities(_cloudTable, new PodCastTableEntity
            {
                PartitionKey    = CloudTableHelper.BeyondPodPodCast.FeedName,
                RowKey          = CloudTableHelper.BeyondPodPodCast.EpisodeName,
                Created         = DateTime.Now,
                EpisodeDuration = CloudTableHelper.BeyondPodPodCast.EpisodeDuration,
                EpisodePosition = CloudTableHelper.BeyondPodPodCast.EpisodePosition
            });

            var newData = CloudTableHelper.BeyondPodPodCast;

            newData.EpisodePosition = 1000;

            await _sut.RunAsync(newData, _cloudTable, _collector, _logger.Object);

            var list = await CloudTableHelper.GetAllCloudTableEntities(_cloudTable);

            Assert.Single(list);
            Assert.Equal(1000, list.First().EpisodePosition);
        }