This dll has dependencies on Newtonsoft.Json

Create sample 10 sample data for the class poco:
List<PocoEvents> EventsList = SamplerServices<PocoEvents>.CreateSampleData(10);

Save sample data for later use.
SamplerServices<PocoEvents>.SaveToFile(EventsList);

Load the saved sample data
var eventList = SamplerServices<PocoEvents>.LoadSavedFile();

Create sample data with options
     SamplerOptions options = new SamplerOptions();
     options.PropertyOptions.Add("Id", SamplerOptions.Options.IsUnique);
     options.PropertyOptions.Add("LongText", SamplerOptions.Options.Paragraph);
     options.PropertyOptions.Add("CreatedDt", SamplerOptions.Options.IsUnique);
     List<PocoEvents> EventsList = SamplerServices<PocoEvents>.CreateSampleData(100, options);


Here is a sample of creating a list of object and saving to a file so the Unit Test always runs against this data sample
public void CreateSample()
        {
            SamplerOptions options = new SamplerOptions();
            options.PropertyDefaults.Add(new PropertiesSettings { PropertyName = "Id", PropertyValue = "1" }, SamplerOptions.Options.DefaultValue);
            options.PropertyOptions.Add("Id", SamplerOptions.Options.Sequential);
            List<Menu> menues = SamplerServices<Menu>.CreateSampleData(15, options);
            List<Category> categories = SamplerServices<Category>.CreateSampleData(3, options);
            categories[0].Name = "Appetizer";
            categories[1].Name = "Entree";
            categories[2].Name = "Desert";

            for (int i = 0; i < 5; i++)
            {
                CreateMenuItem(menues, i);
                menues[i].Category = categories[0];
                menues[i].CategoryId = categories[0].Id;
            }
            for (int i = 5; i < 10; i++)
            {
                CreateMenuItem(menues, i);
                menues[i].Category = categories[0];
                menues[i].CategoryId = categories[1].Id;
            }
            for (int i = 10; i < 15; i++)
            {
                CreateMenuItem(menues, i);
                menues[i].Category = categories[0];
                menues[i].CategoryId = categories[2].Id;
            }
            SamplerServices<Menu>.SaveToFile(menues);
        }

        private static void CreateMenuItem(IList<Menu> menues, int currentCount)
        {
            foreach (var menuItem in SamplerServices<MenuItem>.CreateSampleData(_random.Next(2, 8)))
            {
                menuItem.MenuId = menues[currentCount].Id;
                foreach (var nutrionInformation in SamplerServices<NutrionInformation>.CreateSampleData(_random.Next(3, 5)))
                {
                    nutrionInformation.MenuItemId = menuItem.Id;
                    menuItem.NutriotionInformations.Add(nutrionInformation);
                }
                menues[currentCount].MenuItems.Add(menuItem);
            }
        }

Last edited Oct 2, 2013 at 6:29 PM by jsucupira, version 7

Comments

jsucupira Oct 2, 2013 at 3:55 PM 
For more sample I suggest looking at the Unit Test called "GetSampleDataTest.cs"