Esempio n. 1
0
        public async Task UpsertDynamic_TheDynamicWasntInsertedYet_DynamicIsReturnedWithAllProperties()
        {
            dynamic dyn = new ExpandoObject();

            dyn.FirstItem  = "this is the first item.";
            dyn.SecondItem = 2;

            _tableStorageProvider.Upsert(_tableName, dyn, "pk", "rk");
            await _tableStorageProvider.SaveAsync();

            var result = await _tableStorageProvider.GetAsync(_tableName, "pk", "rk");

            Assert.AreEqual("this is the first item.", result.FirstItem);
            Assert.AreEqual(2, result.SecondItem);
        }
Esempio n. 2
0
        public async Task UpsertDynamic_ItemDoesNotExist_DynamicIsInserted()
        {
            dynamic dyn = new ExpandoObject();

            dyn.FirstItem  = "this is the first item.";
            dyn.SecondItem = 2;

            _tableStorageProvider.Upsert(_tableName, dyn, "pk", "rk");
            await _tableStorageProvider.SaveAsync();

            var result = await _tableStorageProvider.GetAsync(_tableName, "pk", "rk");

            Assert.AreEqual("this is the first item.", result.FirstItem);
            Assert.AreEqual(2, result.SecondItem);
        }
        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 );
        }