Example #1
0
        public void ShouldOverWriteExistingValueIfSameValueIsPutForSameKeyAgain()
        {
            ValueStore valueStore = new ValueStore();
            Guid       g          = Guid.NewGuid();

            valueStore.Put(g, "Stored Value");
            valueStore.Put(g, "Modified Value");

            var retreived = valueStore.GetByKey(g);

            Assert.That(retreived, Is.EqualTo("Modified Value"));
            Assert.That("Modified Value", Is.EqualTo(retreived));
        }
        public void Consume(IEnumerable <DataRowEntity> rows, ValueStore valueStore)
        {
            if (_options == null)
            {
                throw new ArgumentNullException("Init was not called before calling consume");
            }

            using (TextWriter writer = File.AppendText(OutputFolder + "\\output.csv"))
            {
                foreach (var row in rows)
                {
                    StringBuilder sb = new StringBuilder();

                    foreach (var field in row.Fields)
                    {
                        if (field.ProducesValue)
                        {
                            valueStore.Put(field.KeyValue, identityCounter++);
                        }
                        var value = valueStore.GetByKey(field.KeyValue);
                        sb.Append(value);
                        Console.WriteLine(value);
                    }
                    writer.Write(sb.ToString());

                    rowCounter++;
                    _reportInsertion();
                    writer.WriteLine();
                }

                writer.Flush();
            }
        }
Example #3
0
        public void ShouldProduceDataForAllTables()
        {
            ValueStore valuestore = new ValueStore();
            var        dp         = new DataProducer(valuestore);

            var tables = new List <ExecutionTable>();

            tables.Add(new ExecutionTable(customerTable, 1));
            tables.Add(new ExecutionTable(orderTable, 2));

            List <DataRowEntity> rows = new List <DataRowEntity>();

            rows.AddRange(dp.ProduceRows(tables));
            Assert.That(rows.Count, Is.EqualTo(2));

            Assert.That(rows[0].Fields.Count, Is.EqualTo(4));
            AssertFieldsInRowHaveSomeValues(valuestore, rows[0], 2);

            // simulate consuming and producing the identity value of CustomerId
            // this will cause the Order table to have a value for its CustomerId column
            valuestore.Put(rows[0].Fields[0].KeyValue, 1);

            Assert.That(rows[1].Fields.Count, Is.EqualTo(4));

            AssertFieldsInRowHaveSomeValues(valuestore, rows[1], 0);
        }
 private static void PutGeneratedValuesInValueStore(Dictionary <Guid, object> generatedValues, ValueStore valueStore)
 {
     foreach (var key in generatedValues.Keys)
     {
         valueStore.Put(key, generatedValues[key]);
     }
 }
Example #5
0
        public void ShouldBeAbleToPutAndGetValueFromValueStore()
        {
            ValueStore valueStore = new ValueStore();
            Guid       g          = Guid.NewGuid();

            valueStore.Put(g, "Stored Value");

            Assert.That(valueStore.Count, Is.EqualTo(1));

            var retreived = valueStore.GetByKey(g);

            Assert.That(retreived, Is.EqualTo("Stored Value"));
            Assert.That("Stored Value", Is.EqualTo(retreived));
        }
 public void Consume(IEnumerable <DataRowEntity> rows, ValueStore valueStore)
 {
     ValidateInitialized();
     foreach (var row in rows)
     {
         rowCounter++;
         _reportInsertion();
         RowValidator(row);
         foreach (var field in row.Fields)
         {
             if (field.ProducesValue)
             {
                 valueStore.Put(field.KeyValue, identityCounter++);
             }
             var value = valueStore.GetByKey(field.KeyValue);
             ValueValidator(value);
             //    Console.WriteLine(value);
         }
     }
 }