public void RunGenerator(Creator creteEntity, bool saveToDb = true)
        {
            Creator creator = creteEntity;

            for (var i = 0; i < _count; i++)
            {
                if (_listEntity.Count == MaxInChunk && saveToDb)
                {
                    BulkToDb();
                }

                var entity = creator.FactoryMethod(_faker);
                _listEntity.Add(entity);
            }

            if (_listEntity.Any() && saveToDb)
            {
                BulkToDb();
            }

            _db.SaveChanges();
        }
Beispiel #2
0
        public void Execute()
        {
            using (var generateDbContext = new GenerateDbContext())
            {
                generateDbContext.Database.EnsureCreated();

                var project = new Project();
                project.AddMember(new Member {
                    Id = "100", Name = "1000"
                });
                project.SetId("100");

                generateDbContext.Set <Project>().Add(
                    project);

                generateDbContext.SaveChanges();
            }

            using (var generateDbContext = new GenerateDbContext())
            {
                var project = generateDbContext.Set <Project>().Single(e => e.Id == "100");
                Assert.NotNull(project);
            }
        }