Пример #1
0
        public async Task Update_101EntitiesInTheSamePartition_ShouldSucceed()
        {
            string partitionKey  = "123";
            int    expectedCount = 101;

            for (int i = 0; i < expectedCount; i++)
            {
                var item = new DecoratedItem
                {
                    Id   = partitionKey,
                    Name = i.ToString(CultureInfo.InvariantCulture)
                };
                _tableStorageProvider.Add(_tableName, item);
            }
            await _tableStorageProvider.SaveAsync(Execute.InBatches);

            for (int i = 0; i < expectedCount; i++)
            {
                var item = await _tableStorageProvider.GetAsync <DecoratedItem>(_tableName, partitionKey, i.ToString(CultureInfo.InvariantCulture));

                item.Age = 101;
                _tableStorageProvider.Update(_tableName, item);
            }


            await _tableStorageProvider.SaveAsync(Execute.InBatches);


            IEnumerable <DecoratedItem> items = (await _tableStorageProvider.CreateQuery <DecoratedItem>(_tableName).PartitionKeyEquals(partitionKey).Async()).ToList();

            Assert.AreEqual(expectedCount, items.Count());
            Assert.IsFalse(items.Any(i => i.Age != 101));
        }
Пример #2
0
        public async Task <Package> GetPackageByNameAndTagAsync(string name)
        {
            var tableStorage = new AzureTableStorageProvider(storageAccount);

            try
            {
                return(await tableStorage.GetAsync <Package>(PackagesTableName, Package.PACKAGES_PARTITION_NAME, name));
            }
            catch (EntityDoesNotExistException)
            {
                return(null);
            }
        }
Пример #3
0
        public async Task SaveAsync_MultipleOperationTypesOnSamePartitionAndNoConflicts_OperationsSucceed()
        {
            _tableStorageProvider.Add(_tableName, new DecoratedItem {
                Id = "123", Name = "Eve", Age = 34
            });
            await _tableStorageProvider.SaveAsync();

            _tableStorageProvider.Add(_tableName, new DecoratedItem {
                Id = "123", Name = "Ed", Age = 7
            });
            _tableStorageProvider.Upsert(_tableName, new DecoratedItem {
                Id = "123", Name = "Eve", Age = 42
            });
            await _tableStorageProvider.SaveAsync(Execute.Atomically);

            Assert.AreEqual(7, (await _tableStorageProvider.GetAsync <DecoratedItem>(_tableName, "123", "Ed")).Age);
            Assert.AreEqual(42, (await _tableStorageProvider.GetAsync <DecoratedItem>(_tableName, "123", "Eve")).Age);
        }