Пример #1
0
 public void SimpleConfiguration_ConnectionStringIsNull_ThrowsArgumentException()
 {
     // Act and Assert
     Should.Throw <ArgumentException>(() =>
     {
         TableStorageProvider.Configure((string)null);
     });
 }
Пример #2
0
        public HttpResponseMessage Get()
        {
            TableStorageProvider tableStorageProvider = new TableStorageProvider();
            var charData = tableStorageProvider.GetChartData();
            var response = Request.CreateResponse(HttpStatusCode.OK, charData);

            return(response);
        }
Пример #3
0
 public void FullConfiguration_ConfigIsNull_ThrowsAgurmentNullException()
 {
     // Act and Assert
     Should.Throw <ArgumentNullException>(() =>
     {
         TableStorageProvider.Configure((TableStorageConfiguration)null);
     });
 }
Пример #4
0
      public void TestInitialize()
      {
         _tableStorageProvider = new AzureTableStorageProvider( _storageAccount );

         _tableName = _baseTableName + Guid.NewGuid().ToString().Replace( "-", string.Empty );

         var client = new CloudTableClient( new Uri( _storageAccount.TableEndpoint ),
                                         _storageAccount.Credentials );
         client.GetTableReference( _tableName ).CreateAsync().Wait();
      }
Пример #5
0
        public void SimpleConfiguration_ValidConnectionStringToggleDoesNotExist_ThrowsToggleConfigurationError()
        {
            // Arrange
            TableStorageProvider.Configure(TestConfig.ValidConnectionString);

            // Act and Assert
            Should.Throw <ToggleConfigurationError>(() =>
            {
                var toggleValue = sut.EvaluateBooleanToggleValue(new TestFeatureToggle());
            });
        }
Пример #6
0
        public void TestInitialize()
        {
            _tableStorageProvider = new AzureTableStorageProvider(_storageAccount);

            _tableName = _baseTableName + Guid.NewGuid().ToString().Replace("-", string.Empty);

            var client = new CloudTableClient(new Uri(_storageAccount.TableEndpoint),
                                              _storageAccount.Credentials);

            client.GetTableReference(_tableName).CreateAsync().Wait();
        }
Пример #7
0
        protected void ConfigureProvider(bool autoCreateTable = false, bool autoCreateToggle = false)
        {
            var config = new TableStorageConfiguration {
                ConnectionString = "UseDevelopmentStorage=true"
            };

            config.AutoCreateTable   = autoCreateTable;
            config.AutoCreateFeature = autoCreateToggle;
            config.TableName         = tableName;

            TableStorageProvider.Configure(config);
        }
Пример #8
0
        public HttpResponseMessage Post([FromBody] SensorReading sensorReading)
        {
            TableStorageProvider <SensorReadingEntry> storageProvider = new TableStorageProvider <SensorReadingEntry>("SensorData");

            SensorReadingEntry sre = new SensorReadingEntry();

            sre.RowKey   = sensorReading.SensorName;
            sre.Value    = sensorReading.Value;
            sre.UtcTicks = DateTime.UtcNow.Ticks;
            storageProvider.Insert(sre);

            return(Request.CreateResponse <SensorReading>(HttpStatusCode.OK, sensorReading));
        }
        public async Task <ClaimTableEntity> ProcessAsync(ClaimForm claim)
        {
            var table = await TableStoreFactory.CreateAsync(this.connectionString, this.tableName);

            var provider = new TableStorageProvider(table);

            TableOperation retrieveOperation = TableOperation.Retrieve <ClaimTableEntity>(claim.Id.ToString(), claim.Id.ToString());
            var            result            = await provider.QuerySingleAsync(retrieveOperation);

            var target = result.Result as ClaimTableEntity;

            return(target);
        }
Пример #10
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //TableStorageProvider.Configure("UseDevelopmentStorage=true");
            TableStorageProvider.Configure(new TableStorageConfiguration
            {
                ConnectionString  = "UseDevelopmentStorage=true",
                AutoCreateFeature = true,
                AutoCreateTable   = true
            });

            //DocumentDbProvider.Configure("https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==");
            DocumentDbProvider.Configure(new DocumentDbConfiguration
            {
                ServiceEndpoint = "https://localhost:8081",
                AuthKey         = "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==",
                AutoCreateDatabaseAndCollection = true,
                AutoCreateFeature = true
            });
        }
Пример #11
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 );
        }
Пример #12
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 );
        }
Пример #13
0
 public void SetUp()
 {
     InMemoryTableStorageProvider.ResetAllTables();
      _tableStorageProvider = new InMemoryTableStorageProvider();
      _tableStorageProvider.ShouldThrowForReservedPropertyNames = false;
 }
Пример #14
0
        public void TestInitialize()
        {
            _storageAccount = new ConnectionStringCloudStorageAccount( ConfigurationManager.AppSettings["storageConnectionString"] );

             _tableStorageProvider = new AzureTableStorageProvider( _storageAccount );

             _client = new CloudTableClient( _storageAccount.TableEndpoint,
                                         _storageAccount.Credentials );

             _tableName = _baseTableName + Guid.NewGuid().ToString().Replace( "-", string.Empty );

             _client.CreateTable( _tableName );
        }
Пример #15
0
 public void SetUp()
 {
     InMemoryTableStorageProvider.ResetAllTables();
     _tableStorageProvider = new InMemoryTableStorageProvider();
     _tableStorageProvider.ShouldThrowForReservedPropertyNames = false;
 }
Пример #16
0
 public HashRepository( TableStorageProvider tableStorageProvider )
 {
    _tableStorageProvider = tableStorageProvider;
 }
Пример #17
0
        public HttpResponseMessage Get(int noOfValues)
        {
            TableStorageProvider <SensorReadingEntry> storageProvider = new TableStorageProvider <SensorReadingEntry>("SensorData");

            return(Request.CreateResponse <IEnumerable <SensorReadingEntry> >(HttpStatusCode.OK, storageProvider.GetLastValues(100).ToArray()));
        }
Пример #18
0
 public void SetUp()
 {
     InMemoryTableStorageProvider.ResetAllTables();
      _tableStorageProvider = new InMemoryTableStorageProvider();
 }
Пример #19
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();
 }
Пример #20
0
 public HashRepository(TableStorageProvider tableStorageProvider)
 {
     _tableStorageProvider = tableStorageProvider;
 }
Пример #21
0
 public void Setup()
 {
     sut = new TableStorageProvider();
 }
Пример #22
0
        private void EnsureOneItemInContext( TableStorageProvider tableStorageProvider )
        {
            var item = new SimpleDataItem
                    {
                       FirstType = "First",
                       SecondType = 2
                    };

             tableStorageProvider.Add( _tableName, item, _partitionKey, _rowKey );
             tableStorageProvider.Save();
        }
Пример #23
0
 /// <summary>
 /// Creates a new ITableStorageClient instance based on the
 /// passed-in provider.
 /// </summary>
 /// <typeparam name="TElement">The type of table entity.</typeparam>
 /// <param name="config">Configuration to access the Table Storage.
 /// </param>
 /// <param name="provider">Defines the provider used to build the
 /// instance. By default it is set to Azure Table Storage.</param>
 /// <returns>ITableStorageClient instance based on the passed-in
 /// provider.</returns>
 public static ITableStorageClient <TElement> Create <TElement>(
     TableStorageConfig config,
     TableStorageProvider provider = TableStorageProvider.Azure)
     where TElement : ITableEntity, new()
 => provider switch
 {
Пример #24
0
 private ImageProcessingService()
 {
     this.emotionProvider      = new EmotionProvider();
     this.tableStorageProvider = new TableStorageProvider();
     this.reactor = new ImageReactor();
 }
 protected TableStorageToggle()
 {
     ToggleValueProvider = new TableStorageProvider();
 }