0

Is it possbile to configure AutoFixture so that it adheres the entity constraints [from the EDMX file]?

E.g. Consider a snippet from the CSDL section of my EDMX file:

<EntityType Name="RndtAd">
...
<Property Name="AD" Type="Decimal" Precision="12" Scale="0" Nullable="false" />
<Property Name="USERNAME" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
<Property Name="VERSION" Type="Decimal" Precision="12" Scale="4" Nullable="false" />
<Property Name="EFFECTIVE_FROM" Type="DateTime" Precision="3" />
<Property Name="EFFECTIVE_FROM_TZ" Type="DateTime" Precision="7" />
<Property Name="EFFECTIVE_TILL" Type="DateTime" Precision="3" />
<Property Name="EFFECTIVE_TILL_TZ" Type="DateTime" Precision="7" />
<Property Name="IS_TEMPLATE" Type="String" MaxLength="1" FixedLength="true" Unicode="false" />
<Property Name="IS_USER" Type="String" MaxLength="1" FixedLength="true" Unicode="false" />
<Property Name="STRUCT_CREATED" Type="String" MaxLength="1" FixedLength="true" Unicode="false" />
<Property Name="AD_TP" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="PERSON" Type="String" MaxLength="40" FixedLength="false" Unicode="true" />
<Property Name="TITLE" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="FUNCTION_NAME" Type="String" MaxLength="20" FixedLength="false" Unicode="true" />
<Property Name="COMPANY" Type="String" MaxLength="40" FixedLength="false" Unicode="true" />
<Property Name="STREET" Type="String" MaxLength="40" FixedLength="false" Unicode="true" />
...

What I would like if fixture.Create<RndtAd>() generated randomly an entity where all the previous constraints are satisfied.

What options do I have? All suggestions are welcome.

EDIT. I'm not bound to AutoFixture. If there is another tool which does the job, I'm ok with that too.

user92382
  • 369
  • 3
  • 12

2 Answers2

3

AutoFixture has no built-in support for Entity Framework, but during the last couple of years, several people have fought their own battles to integrate the two.

Here's what a Google search turned up for me:

Perhaps you can find some inspiration by looking some of those resources over.

Community
  • 1
  • 1
Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
2

As-is, AutoFixture can't be customized through .EDMX files.

Nikos Baxevanis
  • 10,868
  • 2
  • 46
  • 80