3

I am using NBuilder to create test data and my classes have a large number of properties so manual creation is out of question. Before I used NBuilder I copy pasted some SQL selects to csv files and recreated them in tests using automatic mapping. Now I want to use NBuilder or something else and I face the problem of Entity/DB restrictions.

Is there any way I can tell some of those builders to take into account my Mapping file when generating data. For instance, if there is a mapping

  this.Property(t => t.SomeId)
                .IsFixedLength()
                .HasMaxLength(3);

I would expect the framework to generate test data for that property according to those requirements.

majkinetor
  • 8,730
  • 9
  • 54
  • 72

1 Answers1

1

I wonder if you could use Linq-to-EDMX to access the mapping information for your entities. Having that information you could use NBuilder's CreateNew method do something like this:

// Linq-to-EDMX was used to get the propertyLength value
x => x.SomeId = randomString.Substring(0, propertyLength)
Brad Rem
  • 6,036
  • 2
  • 25
  • 50