public async Task GetAsync_ObjectInsertedIsInheritsDynamicObject_RetrievedProperly() { dynamic item = new DynamicPropertyBag(); item.Foo = "test"; item.Bar = 1; string partitionKey = "partitionKey"; string rowKey = "rowKey"; _tableStorageProvider.Add(_tableName, item, partitionKey, rowKey); await _tableStorageProvider.SaveAsync(); dynamic result = await _tableStorageProvider.GetAsync(_tableName, partitionKey, rowKey); Assert.AreEqual(item.Foo, result.Foo); Assert.AreEqual(item.Bar, result.Bar); }
public async Task AddItem_TypeWithSingleStringProperty_ItemAddedToStore() { var dataItem = new TypeWithStringProperty { FirstType = "b" }; _tableStorageProvider.Add(_tableName, dataItem, _partitionKey, _rowKey); await _tableStorageProvider.SaveAsync(); var result = await _tableStorageProvider.GetAsync <TypeWithStringProperty>(_tableName, _partitionKey, _rowKey); Assert.AreEqual("b", result.FirstType); }
private async Task EnsureOneItemInContext( TableStorageProvider tableStorageProvider ) { var item = new SimpleDataItem { FirstType = "First", SecondType = 2 }; tableStorageProvider.Add( _tableName, item, _partitionKey, _rowKey ); await tableStorageProvider.SaveAsync(); }
private async Task EnsureItemsInContextAsync( TableStorageProvider tableStorageProvider, int count ) { for ( int i = 0; i < count; i++ ) { var item = new SimpleDataItem { FirstType = i.ToString( CultureInfo.InvariantCulture ), SecondType = i }; tableStorageProvider.Add( _tableName, item, _partitionKey, _rowKey + i ); } await tableStorageProvider.SaveAsync(); }
public async Task Update_ItemExistsAndUpdateIsValid_ShouldPerformTheUpdate() { await EnsureOneItemInTableStorageAsync(); var itemToUpdate = await _tableStorageProvider.GetAsync<TypeWithStringProperty>( _tableName, _partitionKey, _rowKey ); string updatedFirstTypeValue = "I am updated"; itemToUpdate.FirstType = updatedFirstTypeValue; _tableStorageProvider = new AzureTableStorageProvider( _storageAccount ); _tableStorageProvider.Update( _tableName, itemToUpdate, _partitionKey, _rowKey ); await _tableStorageProvider.SaveAsync(); var updatedItem = await _tableStorageProvider.GetAsync<TypeWithStringProperty>( _tableName, _partitionKey, _rowKey ); Assert.AreEqual( updatedFirstTypeValue, updatedItem.FirstType ); }
public async Task Upsert_ItemExistsAndIsThenUpdated_ItemIsProperlyUpdated() { var itemToUpsert = new TypeWithStringProperty { FirstType = "first" }; _tableStorageProvider.Upsert( _tableName, itemToUpsert, _partitionKey, _rowKey ); await _tableStorageProvider.SaveAsync(); _tableStorageProvider = new AzureTableStorageProvider( _storageAccount ); itemToUpsert = new TypeWithStringProperty { FirstType = "second" }; _tableStorageProvider.Upsert( _tableName, itemToUpsert, _partitionKey, _rowKey ); await _tableStorageProvider.SaveAsync(); var itemInTable = await _tableStorageProvider.GetAsync<TypeWithStringProperty>( _tableName, _partitionKey, _rowKey ); Assert.AreEqual( itemToUpsert.FirstType, itemInTable.FirstType ); }
public Task SaveChangesAsync() { return(_tableStorageProvider.SaveAsync()); }