Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
      private async Task EnsureOneItemInContext( TableStorageProvider tableStorageProvider )
      {
         var item = new SimpleDataItem
                    {
                       FirstType = "First",
                       SecondType = 2
                    };

         tableStorageProvider.Add( _tableName, item, _partitionKey, _rowKey );
         await tableStorageProvider.SaveAsync();
      }
Ejemplo n.º 4
0
 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();
 }
Ejemplo n.º 5
0
      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 );
      }
Ejemplo n.º 6
0
      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 );
      }
Ejemplo n.º 7
0
 public Task SaveChangesAsync()
 {
     return(_tableStorageProvider.SaveAsync());
 }