예제 #1
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 );
        }
예제 #2
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 );
        }
예제 #3
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 );
        }
예제 #4
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 );
        }
예제 #5
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 );
        }