public void ShouldProduceValuesForIdentityColumns() { ValueStore vs = new ValueStore(); DataProducer producer = new DataProducer(vs); DataRowEntity row = producer.ProduceRow(customerTable, 1); // check that the value of the identity column have not been generated Assert.That(vs.GetByKey(row.Fields[0].KeyValue), Is.Null); IDataConsumer consumer = GetImplementedType(); if (consumer.Init("", options)) { int counter = 0; consumer.ReportInsertionCallback = new Action(() => { counter++; }); consumer.Consume(new List <DataRowEntity> { row }, vs); // now assert that the identity value have been generated by the consumer Assert.That(row.Fields[0].FieldName, Is.EqualTo("CustomerId"), "Column should be customerID"); Assert.That(vs.GetByKey(row.Fields[0].KeyValue), Is.Not.Null, consumer.GetType().ToString()); } }
private static void ConsumeDataAt(int index, IDataConsumer node) { var data = datas[index]; data.consumableCount--; if (data.consumableCount == 0) { datas.RemoveAt(index); } node.Consume(data.data); }
public void ShouldConsumeAllValues() { IDataConsumer consumer = GetImplementedType(); consumer.Init("", null); int rowCount = 0; consumer.ReportInsertionCallback = new Action(() => { rowCount++; }); consumer.Consume(tenRowsDataSet, valueStore); Assert.That(rowCount, Is.EqualTo(10)); }
public void ShouldCountNumberOfRowsConsumed() { IDataConsumer consumer = GetImplementedType(); consumer.Init("", null); int rowCount = 0; consumer.ReportInsertionCallback = new Action(() => { rowCount++; }); consumer.Consume(singleRowDataSet, valueStore); Assert.That(rowCount, Is.EqualTo(1)); }
public void ShouldConsumeAllValues() { IDataConsumer consumer = GetImplementedType(); if (consumer.Init("", options)) { int rowCount = 0; consumer.ReportInsertionCallback = new Action(() => { rowCount++; }); consumer.Consume(tenRowsDataSet, valueStore); Assert.That(rowCount, Is.EqualTo(10), "Total rows does not match produced rows"); } }
public void ShouldThrowExceptionIfNotInitiatedBeforeRunning() { IDataConsumer consumer = GetImplementedType(); bool exceptionHappened = false; try { consumer.Consume(new List <DataRowEntity>(), valueStore); } catch (System.Exception) { exceptionHappened = true; } Assert.That(exceptionHappened); }
public void ShouldThrowExceptionIfConsumingNull() { IDataConsumer consumer = GetImplementedType(); bool exceptionHappened = false; try { consumer.Init("", options); consumer.Consume(null, valueStore); } catch (System.Exception) { exceptionHappened = true; } Assert.That(exceptionHappened); }
public static void Consume(IDataConsumer node) { string id = node.ID; if (string.IsNullOrEmpty(id)) { if (datas.Count > 0) { ConsumeDataAt(datas.Count - 1, node); return; } } for (int i = datas.Count - 1; i >= 0; i--) { if (datas[i].id == id) { ConsumeDataAt(i, node); return; } } node.Consume(null); }