public void PropertyHasBeenAdded() { // Arrange IStorageTableClient client = CreateTableClient(); IStorageTable table = client.GetTableReference("table"); StubTableEntityWriter <DynamicTableEntity> writer = new StubTableEntityWriter <DynamicTableEntity>(); Type valueType = typeof(TableEntityWriter <DynamicTableEntity>); TableEntityCollectorBinder <DynamicTableEntity> product = new TableEntityCollectorBinder <DynamicTableEntity>(table, writer, valueType); DynamicTableEntity value = new DynamicTableEntity { PartitionKey = "PK", RowKey = "RK", Properties = new Dictionary <string, EntityProperty> { { "Item", new EntityProperty("Foo") } } }; writer.Add(value); // Act var parameterLog = product.GetStatus() as TableParameterLog; // Assert Assert.Equal(1, parameterLog.EntitiesWritten); Assert.Equal(0, writer.TimesPartitionFlushed); }
public void MaximumBatchSizeFlushes() { // Arrange TableClient table = Mock.Of <TableClient>(); StubTableEntityWriter <TableEntity> writer = new StubTableEntityWriter <TableEntity>(); Type valueType = typeof(TableEntityWriter <TableEntity>); TableEntityCollectorBinder <TableEntity> product = new TableEntityCollectorBinder <TableEntity>(table, writer, valueType); TableEntity value = new TableEntity { PartitionKey = "PK", RowKey = "RK", ["Item"] = ("Foo") }; for (int i = 0; i < TableEntityWriter <ITableEntity> .MaxBatchSize + 1; i++) { value.RowKey = "RK" + i; writer.Add(value); } // Act var parameterLog = product.GetStatus() as TableParameterLog; // Assert Assert.AreEqual(TableEntityWriter <ITableEntity> .MaxBatchSize + 1, parameterLog.EntitiesWritten); Assert.AreEqual(1, writer.TimesPartitionFlushed); }
public void PropertyHasBeenReplaced() { // Arrange TableClient table = Mock.Of <TableClient>(); StubTableEntityWriter <TableEntity> writer = new StubTableEntityWriter <TableEntity>(); Type valueType = typeof(TableEntityWriter <TableEntity>); TableEntityCollectorBinder <TableEntity> product = new TableEntityCollectorBinder <TableEntity>(table, writer, valueType); TableEntity value = new TableEntity { PartitionKey = "PK", RowKey = "RK", ["Item"] = ("Foo") }; writer.Add(value); // Act var parameterLog = product.GetStatus() as TableParameterLog; // Assert Assert.AreEqual(1, parameterLog.EntitiesWritten); Assert.AreEqual(0, writer.TimesPartitionFlushed); // Calling again should yield no changes Assert.AreEqual(1, parameterLog.EntitiesWritten); // Assert Assert.AreEqual(0, writer.TimesPartitionFlushed); // Add same value again. writer.Add(value); // Act parameterLog = product.GetStatus() as TableParameterLog; // Assert Assert.AreEqual(2, parameterLog.EntitiesWritten); Assert.AreEqual(1, writer.TimesPartitionFlushed); }
public void MaximumBatchSizeFlushes() { // Arrange var client = CreateTableClient(); CloudTable table = client.GetTableReference("table"); StubTableEntityWriter <DynamicTableEntity> writer = new StubTableEntityWriter <DynamicTableEntity>(); Type valueType = typeof(TableEntityWriter <DynamicTableEntity>); TableEntityCollectorBinder <DynamicTableEntity> product = new TableEntityCollectorBinder <DynamicTableEntity>(table, writer, valueType); DynamicTableEntity value = new DynamicTableEntity { PartitionKey = "PK", RowKey = "RK", Properties = new Dictionary <string, EntityProperty> { { "Item", new EntityProperty("Foo") } } }; for (int i = 0; i < TableEntityWriter <ITableEntity> .MaxBatchSize + 1; i++) { value.RowKey = "RK" + i; writer.Add(value); } // Act var parameterLog = product.GetStatus() as TableParameterLog; // Assert Assert.Equal(TableEntityWriter <ITableEntity> .MaxBatchSize + 1, parameterLog.EntitiesWritten); Assert.Equal(1, writer.TimesPartitionFlushed); }
public void ValueHasNotChanged() { // Arrange var table = Mock.Of <TableClient>(); StubTableEntityWriter <TableEntity> writer = new StubTableEntityWriter <TableEntity>(); Type valueType = typeof(TableEntityWriter <TableEntity>); TableEntityCollectorBinder <TableEntity> product = new TableEntityCollectorBinder <TableEntity>(table, writer, valueType); // Act var parameterLog = product.GetStatus() as TableParameterLog; // Assert Assert.Null(parameterLog); }
public void ValueHasNotChanged() { // Arrange IStorageTableClient client = CreateTableClient(); IStorageTable table = client.GetTableReference("table"); StubTableEntityWriter <DynamicTableEntity> writer = new StubTableEntityWriter <DynamicTableEntity>(); Type valueType = typeof(TableEntityWriter <DynamicTableEntity>); TableEntityCollectorBinder <DynamicTableEntity> product = new TableEntityCollectorBinder <DynamicTableEntity>(table, writer, valueType); // Act var parameterLog = product.GetStatus() as TableParameterLog; // Assert Assert.Null(parameterLog); }