public void ShouldBeAbleToAddSameFieldMultipleTimes_ForNow() { var table = new TableEntity("dbo", "Customer"); var row = new DataRowEntity(table); row.AddField("customerid", Guid.NewGuid(), new ColumnDataTypeDefinition("int", false), true); row.AddField("customerid", Guid.NewGuid(), new ColumnDataTypeDefinition("int", false), true); row.AddField("customerid", Guid.NewGuid(), new ColumnDataTypeDefinition("int", false), true); row.AddField("customerid", Guid.NewGuid(), new ColumnDataTypeDefinition("int", false), true); Assert.That(row.Fields.Count, Is.EqualTo(4)); foreach (var f in row.Fields) { Assert.That(f, Is.Not.Null); } }
public void ShouldBeAbleToIterateThroughTheFields() { var table = new TableEntity("dbo", "Customer"); var row = new DataRowEntity(table); row.AddField("customerid", Guid.NewGuid(), new ColumnDataTypeDefinition("int", false), true); row.AddField("name", Guid.NewGuid(), new ColumnDataTypeDefinition("varchar(100)", false), false); row.AddField("vip", Guid.NewGuid(), new ColumnDataTypeDefinition("bit", false), false); row.AddField("lastseen", Guid.NewGuid(), new ColumnDataTypeDefinition("datetime", false), false); Assert.That(row.Fields.Count, Is.EqualTo(4)); foreach (var f in row.Fields) { Assert.That(f, Is.Not.Null); } }
public void ShouldAddFieldsToRow() { var table = new TableEntity("dbo", "Customer"); var row = new DataRowEntity(table); row.AddField("customerid", Guid.NewGuid(), new ColumnDataTypeDefinition("int", false), true); Assert.That(row.Fields.Count, Is.EqualTo(1)); }
public DataRowEntity ProduceRow(ExecutionTable current) { ValidateUtil.ValidateNotNull(current, "table"); var row = new DataRowEntity(current.Table); foreach (var col in current.Table.Columns) { var value = col.GenerateValue(current.N); Guid key; if (col.Generator.IsTakingValueFromOtherColumn) { if (value.GetType().Equals(typeof(Guid))) { if (!columnLastKeyMap.TryGetValue((Guid)value, out key)) { throw new ArgumentNullException("Trying to take value from column that have not yet generated any value"); } } else { throw new InvalidCastException("The generator returned a non-GUID type as key when generating value from other column"); } } else if (col.IsIdentity) { key = col.ColumnIdentity; value = null; ValueStorage.Put(key, value); columnLastKeyMap[col.ColumnIdentity] = key; } else { key = Guid.NewGuid(); columnLastKeyMap[col.ColumnIdentity] = key; ValueStorage.Put(key, value); } row.AddField(col.ColumnName, key, col.ColumnDataType, col.IsIdentity); } return(row); }