Example #1
0
        public void UseSuppliedResourceDataTest()
        {
            GenFu.Configure().Data(PropertyType.FirstNames, @"testdata\singlename.txt");
            var people = A.ListOf <Person>(25);

            Assert.Equal(25, people.Where(p => p.FirstName == "Angela").Count());
        }
Example #2
0
        public static void Populate(string connectionString)
        {
            GenFu.Configure <Genre>().Fill(x => x.Name).AsMusicGenreName();
            GenFu.Configure <Artist>().Fill(x => x.Name).AsMusicArtistName();
            GenFu.Configure <Album>().Fill(x => x.AlbumArtUrl, "/Content/Images/placeholder.gif").Fill(x => x.Price).WithinRange(100, 500);
            var rand = new System.Random(100);

            using (var conn = new Npgsql.NpgsqlConnection(connectionString))
            {
                if (conn.ExecuteScalar <int>("select count(1) from albums ") == 0)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        var genre    = A.New <Genre>();
                        var artist   = A.New <Artist>();
                        var genreid  = conn.ExecuteScalar <int>("insert into genres (name,description) values (@name,@description) returning genreid;", new{ genre.Name, genre.Description });
                        var artistid = conn.ExecuteScalar <int>("insert into artists (name) values (@name) returning artistid;", new{ artist.Name });
                        var albums   = A.ListOf <Album>(10);
                        albums.ForEach(a => {
                            conn.Execute("insert into albums(genreid,artistid,title,price,albumarturl) values(@genreid,@artistid,@title,@price,@albumarturl) returning albumid;", new { genreid, artistid, a.Title, a.Price, a.AlbumArtUrl });
                        });
                    }
                }
            }
        }
Example #3
0
        public void Should_fill_from_a_configured_list_using_lambda()
        {
            GenFu.Reset();
            GenFu.Configure <BlogPost>().Fill(x => x.Tags, () => new List <string> {
                "default"
            });
            var result = A.New <BlogPost>();

            Assert.Equal("default", result.Tags.Single());
        }
Example #4
0
        public void Should_fill_a_list_of_objects_from_a_configured_list_using_lambda()
        {
            GenFu.Reset();
            GenFu.Configure <BlogPost>().Fill(x => x.Tags, () => new List <string> {
                "default"
            });
            var results = A.ListOf <BlogPost>(5);

            foreach (var result in results)
            {
                Assert.Equal("default", result.Tags.Single());
            }
        }
Example #5
0
        /// <summary>
        ///     The of.
        /// </summary>
        /// <param name="count">
        ///     The count.
        /// </param>
        /// <param name="customFiller">
        ///     The custom filler.
        /// </param>
        /// <typeparam name="T">
        /// </typeparam>
        /// <returns>
        ///     The <see cref="IEnumerable{T}" />.
        /// </returns>
        public static IEnumerable <T> Of <T>(int count = 10, Func <T, T> customFiller = null) where T : new()
        {
            while (count-- > 0)
            {
                var item = GenFu.New <T>();
                if (customFiller != null)
                {
                    item = customFiller(item);
                }

                yield return(item);
            }
        }
Example #6
0
 public GenFuDefaulturator(GenFu genfu, FillerManager maggie)
 {
     _genfu = genfu;
     _fillerManager = maggie;
 }