コード例 #1
0
ファイル: BasicFillTests.cs プロジェクト: sezginakman/GenFu
        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());
        }
コード例 #2
0
ファイル: SeedData.cs プロジェクト: sphiecoh/MusicStore
        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 });
                        });
                    }
                }
            }
        }
コード例 #3
0
ファイル: GenFuTests.cs プロジェクト: marcoregueira/GenFu
        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());
        }
コード例 #4
0
ファイル: GenFuTests.cs プロジェクト: marcoregueira/GenFu
        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());
            }
        }