开发者

Generating fake instances at runtime

开发者 https://www.devze.com 2023-01-17 17:32 出处:网络
I\'m looking for an utility class to generate fake entity instances at runtime. I\'m implementi开发者_StackOverflow中文版ng a ASP.NET MVC3 website using EF4 with a code-first approach, so I\'d like to

I'm looking for an utility class to generate fake entity instances at runtime. I'm implementi开发者_StackOverflow中文版ng a ASP.NET MVC3 website using EF4 with a code-first approach, so I'd like to run the site before creating any database. The fake instances should contain valid data (hopefully reflecting the various DataAnnotation attributes used in each class definition).


Are you looking for a Framework like FakeItEasy?

Description taken from the website:

A .Net dynamic fake framework for creating
all types of fake objects, mocks, stubs etc.

  * Easier semantics, all fake objects are
    just that - fakes - the use of the fakes
    determines whether they're mocks or stubs.
  * Context aware fluent interface guides the developer.
  * Full VB.Net support. 

Designed for ease of use and for compatibility with both C# and VB.Net. 


The place to start is to look at the "Seed Data" example in this post: http://blogs.msdn.com/b/adonet/archive/2010/09/02/ef-feature-ctp4-dbcontext-and-databases.aspx

This will allow you to write the necessary routines to populate your test data


We use Console Apps in our projects to generate anything we need for testing are to start an install.

0

精彩评论

暂无评论...
验证码 换一张
取 消