예제 #1
0
        public static void ClassInit(TestContext context)
        {
            BaseDatabaseTest.CleanUpDatabase();

            using (var db = new ProducerContext())
            {
                var app = new Turbine.Data.Entities.Application {
                    Name = "ACM", Version = "7.3"
                };
                db.Applications.Add(app);
                var user = new Turbine.Data.Entities.User {
                    Name = username
                };
                db.Users.Add(user);
                db.SaveChanges();
            }
            using (var db = new ProducerContext())
            {
                var item = db.Applications.Single(s => s.Name == "ACM");
                item.InputFileTypes.Add(new Turbine.Data.Entities.InputFileType
                {
                    Id       = Guid.NewGuid(),
                    Name     = "configuration",
                    Required = true,
                    Type     = "plain/text"
                });
                item.InputFileTypes.Add(new Turbine.Data.Entities.InputFileType
                {
                    Id       = Guid.NewGuid(),
                    Name     = "aspenfile",
                    Required = true,
                    Type     = "plain/text"
                });
                db.SaveChanges();
            }
            using (var db = new ProducerContext())
            {
                var app  = db.Applications.Single(s => s.Name == "ACM");
                var user = db.Users.Single(u => u.Name == username);
                var sim  = new Turbine.Data.Entities.Simulation
                {
                    Id          = Guid.NewGuid(),
                    Application = app,
                    Create      = DateTime.UtcNow,
                    Name        = "Test",
                    Update      = DateTime.UtcNow,
                    User        = user
                };
                db.Simulations.Add(sim);
                db.SaveChanges();
            }
        }
예제 #2
0
        public static void Initialize(TestContext context)
        {
            BaseDatabaseTest.CleanUpDatabase();

            using (var db = new ProducerContext())
            {
                var app = new Turbine.Data.Entities.Application {
                    Name = "ACM", Version = "7.3"
                };
                db.Applications.Add(app);
                var user = new Turbine.Data.Entities.User {
                    Name = userName
                };
                db.Users.Add(user);
                db.SaveChanges();
            }
            using (var db = new ProducerContext())
            {
                var item = db.Applications.Single(s => s.Name == "ACM");
                item.InputFileTypes.Add(new Turbine.Data.Entities.InputFileType
                {
                    Id       = Guid.NewGuid(),
                    Name     = "configuration",
                    Required = true,
                    Type     = "plain/text"
                });
                item.InputFileTypes.Add(new Turbine.Data.Entities.InputFileType
                {
                    Id       = Guid.NewGuid(),
                    Name     = "aspenfile",
                    Required = true,
                    Type     = "plain/text"
                });
                db.SaveChanges();
            }
            using (var db = new ProducerContext())
            {
                var app  = db.Applications.Single(s => s.Name == "ACM");
                var user = db.Users.Single(u => u.Name == userName);
                var sim  = new Turbine.Data.Entities.Simulation
                {
                    Id          = Guid.NewGuid(),
                    Application = app,
                    Create      = DateTime.UtcNow,
                    Name        = simulationName,
                    Update      = DateTime.UtcNow,
                    User        = user
                };
                db.Simulations.Add(sim);
                db.SaveChanges();
            }
            using (var db = new ProducerContext())
            {
                var item = new Turbine.Data.Entities.Session
                {
                    Id          = sessionId,
                    Description = "testing simulation",
                    Create      = DateTime.UtcNow
                };
                db.Sessions.Add(item);
                db.SaveChanges();
            }


            List <Turbine.Data.Entities.Job> jobsList = new List <Turbine.Data.Entities.Job>();

            // Session
            using (var db = new ProducerContext())
            {
                var item       = db.Sessions.Single(s => s.Id == sessionId);
                var user       = db.Users.Single(u => u.Name == userName);
                var simulation = db.Simulations.Single(s => s.Name == simulationName);

                for (int i = 0; i < 10; i++)
                {
                    var job = new Turbine.Data.Entities.Job
                    {
                        Id         = Guid.NewGuid(),
                        Session    = item,
                        Create     = DateTime.UtcNow,
                        State      = "success",
                        User       = user,
                        Simulation = simulation
                    };
                    jobsList.Add(job);
                    db.Jobs.Add(job);
                }

                db.SaveChanges();
            }


            using (var db = new ProducerContext())
            {
                var session = db.Sessions.Single(s => s.Id == sessionId);
                var item    = new Turbine.Data.Entities.Generator
                {
                    Id      = generatorId,
                    Page    = 1,
                    Session = session,
                    Create  = DateTime.UtcNow
                };
                db.Generators.Add(item);
                db.SaveChanges();
            }

            using (var db = new ProducerContext())
            {
                var generator = db.Generators.Single(g => g.Id == generatorId);
                var session   = db.Sessions.Single(s => s.Id == sessionId);

                Debug.WriteLine("Generator Page num: " + generator.Page);

                foreach (var job in session.Jobs)
                {
                    var item = new Turbine.Data.Entities.GeneratorJob
                    {
                        Id        = Guid.NewGuid(),
                        Page      = 2,
                        Generator = generator,
                        Job       = job
                    };
                    db.GeneratorJobs.Add(item);
                }

                db.SaveChanges();
            }
        }
예제 #3
0
 public static void ClassInit(TestContext context)
 {
     BaseDatabaseTest.CleanUpDatabase();
 }