コード例 #1
0
        private void EnsureOneItemInContext( TableStorageProvider tableStorageProvider )
        {
            var item = new SimpleDataItem
                    {
                       FirstType = "First",
                       SecondType = 2
                    };

             tableStorageProvider.Add( _tableName, item, _partitionKey, _rowKey );
             tableStorageProvider.Save();
        }
コード例 #2
0
        public void Upsert_ItemExistsAndIsThenUpdated_ItemIsProperlyUpdated()
        {
            var itemToUpsert = new TypeWithStringProperty
             {
            FirstType = "first"
             };

             _tableStorageProvider.Upsert( _tableName, itemToUpsert, _partitionKey, _rowKey );
             _tableStorageProvider.Save();

             _tableStorageProvider = new AzureTableStorageProvider( _storageAccount );
             itemToUpsert = new TypeWithStringProperty { FirstType = "second" };

             _tableStorageProvider.Upsert( _tableName, itemToUpsert, _partitionKey, _rowKey );
             _tableStorageProvider.Save();

             var itemInTable = _tableStorageProvider.Get<TypeWithStringProperty>( _tableName, _partitionKey, _rowKey );

             Assert.AreEqual( itemToUpsert.FirstType, itemInTable.FirstType );
        }
コード例 #3
0
 private void EnsureItemsInContext( 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 );
      }
      tableStorageProvider.Save();
 }
コード例 #4
0
        public void Update_ItemExistsAndUpdateIsValid_ShouldPerformTheUpdate()
        {
            EnsureOneItemInTableStorage();

             var itemToUpdate = _tableStorageProvider.Get<TypeWithStringProperty>( _tableName, _partitionKey, _rowKey );

             string updatedFirstTypeValue = "I am updated";
             itemToUpdate.FirstType = updatedFirstTypeValue;

             _tableStorageProvider = new AzureTableStorageProvider( _storageAccount );
             _tableStorageProvider.Update( _tableName, itemToUpdate, _partitionKey, _rowKey );
             _tableStorageProvider.Save();

             var updatedItem = _tableStorageProvider.Get<TypeWithStringProperty>( _tableName, _partitionKey, _rowKey );

             Assert.AreEqual( updatedFirstTypeValue, updatedItem.FirstType );
        }