Exemplo n.º 1
0
        public void Upsert_ExistingItemIsUpsertedInOneInstanceAndNotSaved_ShouldBeUnaffectedInOtherInstances()
        {
            var secondStorageProvider = new InMemoryTableStorageProvider();
             var item = new SimpleDataItem
                          {
                             FirstType = "first"
                          };

             _tableStorageProvider.Add( _tableName, item, _partitionKey, _rowKey );
             _tableStorageProvider.Save();

             item.FirstType = "second";
             _tableStorageProvider.Upsert( _tableName, item, _partitionKey, _rowKey );

             var result = secondStorageProvider.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );

             Assert.AreEqual( "first", result.FirstType );
        }
Exemplo n.º 2
0
        public void AddItem_TwoMemoryContexts_ThePrimaryContextsUncommitedStoreShouldBeUnchangedWhenAnotherIsCreated()
        {
            InMemoryTableStorageProvider.ResetAllTables();
             var firstContext = new InMemoryTableStorageProvider();

             var expectedItem = new SimpleDataItem
                              {
                                 FirstType = "a",
                                 SecondType = 1
                              };

             firstContext.Add( _tableName, expectedItem, _partitionKey, _rowKey );
             firstContext.Save();

             new InMemoryTableStorageProvider();

             var item = firstContext.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );

             Assert.AreEqual( expectedItem.FirstType, item.FirstType );
             Assert.AreEqual( expectedItem.SecondType, item.SecondType );
        }
Exemplo n.º 3
0
        public void AddItem_TwoMemoryContextsAndItemAddedButNotSavedInFirstContext_TheSecondContextWontSeeAddedItem()
        {
            InMemoryTableStorageProvider.ResetAllTables();

             var firstTableStorageProvider = new InMemoryTableStorageProvider();
             var secondTableStorageProvider = new InMemoryTableStorageProvider();

             firstTableStorageProvider.Add( _tableName, new SimpleDataItem
                                        {
                                           FirstType = "a",
                                           SecondType = 1
                                        }, _partitionKey, _rowKey );

             secondTableStorageProvider.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );
        }
Exemplo n.º 4
0
        public void Delete_ItemExistsInAnotherInstancesTempStore_ItemIsNotDeleted()
        {
            var dataItem = new SimpleDataItem();
             var secondTableStorageProvider = new InMemoryTableStorageProvider();
             secondTableStorageProvider.Add( _tableName, dataItem, _partitionKey, _rowKey );

             _tableStorageProvider.Delete( _tableName, _partitionKey, _rowKey );
             _tableStorageProvider.Save();

             secondTableStorageProvider.Save();

             var instance = secondTableStorageProvider.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );
             Assert.IsNotNull( instance );
        }
Exemplo n.º 5
0
        public void Delete_ItemExistsAndTwoInstancesTryToDelete_ItemIsNotFoundInEitherCase()
        {
            var dataItem = new SimpleDataItem();
             _tableStorageProvider.Add( _tableName, dataItem, _partitionKey, _rowKey );
             _tableStorageProvider.Save();

             var firstTableStorageProvider = new InMemoryTableStorageProvider();
             var secondTableStorageProvider = new InMemoryTableStorageProvider();

             firstTableStorageProvider.Delete( _tableName, _partitionKey, _rowKey );
             firstTableStorageProvider.Save();
             secondTableStorageProvider.Delete( _tableName, _partitionKey, _rowKey );
             secondTableStorageProvider.Save();

             bool instanceOneExisted = false;
             bool instanceTwoExisted = false;

             try
             {
            firstTableStorageProvider.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );
            instanceOneExisted = true;
             }
             catch ( EntityDoesNotExistException )
             {
             }

             try
             {
            secondTableStorageProvider.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );
            instanceTwoExisted = true;
             }
             catch ( EntityDoesNotExistException )
             {
             }

             Assert.IsFalse( instanceOneExisted );
             Assert.IsFalse( instanceTwoExisted );
        }
Exemplo n.º 6
0
        public void AddItem_TwoMemoryContexts_TheSecondContextWillSeeAddedAndSavedItem()
        {
            InMemoryTableStorageProvider.ResetAllTables();
             var firstTableStorageProvider = new InMemoryTableStorageProvider();
             var secondTableStorageProvider = new InMemoryTableStorageProvider();

             var expectedItem = new SimpleDataItem
                              {
                                 FirstType = "a",
                                 SecondType = 1
                              };

             firstTableStorageProvider.Add( _tableName, expectedItem, _partitionKey, _rowKey );
             firstTableStorageProvider.Save();

             var item = secondTableStorageProvider.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );

             Assert.AreEqual( expectedItem.FirstType, item.FirstType );
             Assert.AreEqual( expectedItem.SecondType, item.SecondType );
        }
Exemplo n.º 7
0
        public void AddItem_TwoMemoryContexts_TheSecondContextWillNotSeeAddedAndSavedItem_WithInstanceAccount()
        {
            InMemoryTableStorageProvider.ResetAllTables();
             var firstTableStorageProvider = new InMemoryTableStorageProvider( new MemoryStorageAccount() );
             var secondTableStorageProvider = new InMemoryTableStorageProvider( new MemoryStorageAccount() );

             var expectedItem = new SimpleDataItem
             {
            FirstType = "a",
            SecondType = 1
             };

             firstTableStorageProvider.Add( _tableName, expectedItem, _partitionKey, _rowKey );
             firstTableStorageProvider.Save();

             bool hasThrown = false;
             try
             {
            secondTableStorageProvider.Get<SimpleDataItem>( _tableName, _partitionKey, _rowKey );
             }
             catch ( EntityDoesNotExistException )
             {
            hasThrown = true;
             }

             Assert.IsTrue( hasThrown );
        }