コード例 #1
0
        private static void TestSelectWithWhereClause()
        {
            LoadTestingContext          context          = LoadTestingContext.Create(new WebConfigConnectionStringRepository());
            Task <List <AgentMongoDb> > germanAgentsTask = context.Agents.Find(a => a.Location.Country == "Germany").ToListAsync();

            Task.WaitAll(germanAgentsTask);
            List <AgentMongoDb> germanAgents = germanAgentsTask.Result;

            foreach (AgentMongoDb agent in germanAgents)
            {
                Debug.WriteLine(agent.Location.City);
            }

            Guid agentDomainGuid = Guid.Parse("7c9eb839-2c1c-4ae9-8140-170917c975e1");
            Task <AgentMongoDb> singleAgentByIdTask = context.Agents.Find(a => a.DomainId == agentDomainGuid).SingleOrDefaultAsync();

            Task.WaitAll(singleAgentByIdTask);
            AgentMongoDb singleAgentById = singleAgentByIdTask.Result;

            Debug.WriteLine(singleAgentById.Location.City);

            Task <List <AgentMongoDb> > germanAgentsWithBuilderTask = context.Agents
                                                                      .Find(Builders <AgentMongoDb> .Filter.Eq <string>(a => a.Location.Country, "Germany")).ToListAsync();

            Task.WaitAll(germanAgentsWithBuilderTask);
            List <AgentMongoDb> germanAgentsWithBuilder = germanAgentsWithBuilderTask.Result;

            foreach (AgentMongoDb agent in germanAgentsWithBuilder)
            {
                Debug.WriteLine(agent.Location.City);
            }
        }
コード例 #2
0
        private static void TestSelectAllNoFilter()
        {
            LoadTestingContext             context         = LoadTestingContext.Create(new WebConfigConnectionStringRepository());
            Task <List <EngineerMongoDb> > dbEngineersTask = context.Engineers.Find(x => true).ToListAsync();

            Task.WaitAll(dbEngineersTask);
            List <EngineerMongoDb> dbEngineers = dbEngineersTask.Result;

            foreach (EngineerMongoDb eng in dbEngineers)
            {
                Debug.WriteLine(eng.Name);
            }
        }
コード例 #3
0
        private static void TestInsertion()
        {
            LoadTestingContext context     = LoadTestingContext.Create(new WebConfigConnectionStringRepository());
            CustomerMongoDb    newCustomer = new CustomerMongoDb()
            {
                DomainId   = Guid.NewGuid(),
                DbObjectId = ObjectId.GenerateNewId(),
                Name       = "Brand new customer"
            };
            Task insertionTask = context.Customers.InsertOneAsync(newCustomer);

            Task.WaitAll(insertionTask);
        }
コード例 #4
0
        private static void TestUpdate()
        {
            LoadTestingContext context = LoadTestingContext.Create(new WebConfigConnectionStringRepository());
            Guid existingAgentGuid     = Guid.Parse("7c9eb839-2c1c-4ae9-8140-170917c975e1");
            UpdateDefinition <AgentMongoDb> agentUpdateDefinition = Builders <AgentMongoDb> .Update.Set <string>(a => a.Location.City, "Munich");

            Task <AgentMongoDb> replacementTask = context.Agents.FindOneAndUpdateAsync(a => a.DomainId == existingAgentGuid, agentUpdateDefinition);

            Task.WaitAll(replacementTask);

            AgentMongoDb replacementResult = replacementTask.Result;

            Debug.WriteLine(string.Concat(replacementResult.Location.City, ", ", replacementResult.DomainId));
        }
コード例 #5
0
        private static void TestReplacement()
        {
            LoadTestingContext context = LoadTestingContext.Create(new WebConfigConnectionStringRepository());

            Guid existingProjectId            = Guid.Parse("1d9fd06f-66d6-41f6-847d-f80dc48d4ede");
            Task <ProjectMongoDb> projectTask = context.Projects.Find(p => p.DomainId == existingProjectId).SingleOrDefaultAsync();

            Task.WaitAll(projectTask);
            ProjectMongoDb project = projectTask.Result;

            project.Description.LongDescription  = "This is an updated long description";
            project.Description.ShortDescription = "This is an updated short description";
            Task <ProjectMongoDb> replacementTask = context.Projects.FindOneAndReplaceAsync(p => p.DbObjectId == project.DbObjectId, project);
        }
コード例 #6
0
        public IList <Loadtest> GetLoadtestsForTimePeriod(DateTime searchStartDateUtc, DateTime searchEndDateUtc)
        {
            LoadTestingContext context = LoadTestingContext.Create(base.ConnectionStringRepository);

            var dateQueryBuilder = Builders <LoadtestMongoDb> .Filter;
            var startDateBeforeSearchStartFilter = dateQueryBuilder.Lte <DateTime>(l => l.Parameters.StartDateUtc, searchStartDateUtc);
            var endDateAfterSearchStartFilter    = dateQueryBuilder.Gte <DateTime>(l => l.Parameters.ExpectedEndDateUtc, searchStartDateUtc);
            var firstPartialDateQuery            = dateQueryBuilder.And(new List <FilterDefinition <LoadtestMongoDb> >()
            {
                startDateBeforeSearchStartFilter, endDateAfterSearchStartFilter
            });

            var startDateBeforeSearchEndFilter = dateQueryBuilder.Lte <DateTime>(l => l.Parameters.StartDateUtc, searchEndDateUtc);
            var endDateAfterSearchEndFilter    = dateQueryBuilder.Gte <DateTime>(l => l.Parameters.ExpectedEndDateUtc, searchEndDateUtc);
            var secondPartialDateQuery         = dateQueryBuilder.And(new List <FilterDefinition <LoadtestMongoDb> >()
            {
                startDateBeforeSearchEndFilter, endDateAfterSearchEndFilter
            });

            var thirdPartialDateQuery = dateQueryBuilder.And(new List <FilterDefinition <LoadtestMongoDb> >()
            {
                startDateBeforeSearchStartFilter, endDateAfterSearchEndFilter
            });

            var startDateAfterSearchStartFilter = dateQueryBuilder.Gte <DateTime>(l => l.Parameters.StartDateUtc, searchStartDateUtc);
            var endDateBeforeSearchEndFilter    = dateQueryBuilder.Lte <DateTime>(l => l.Parameters.ExpectedEndDateUtc, searchEndDateUtc);
            var fourthPartialQuery = dateQueryBuilder.And(new List <FilterDefinition <LoadtestMongoDb> >()
            {
                startDateAfterSearchStartFilter, endDateBeforeSearchEndFilter
            });

            var ultimateQuery = dateQueryBuilder.Or(new List <FilterDefinition <LoadtestMongoDb> >()
            {
                firstPartialDateQuery, secondPartialDateQuery, thirdPartialDateQuery, fourthPartialQuery
            });

            List <LoadtestMongoDb> mongoDbLoadtestsInSearchPeriod = context.Loadtests.Find(ultimateQuery)
                                                                    .ToList();
            List <Loadtest> loadtestsInSearchPeriod = mongoDbLoadtestsInSearchPeriod.ConvertToDomains().ToList();

            return(loadtestsInSearchPeriod);
        }
コード例 #7
0
        public void AddOrUpdateLoadtests(AddOrUpdateLoadtestsValidationResult addOrUpdateLoadtestsValidationResult)
        {
            LoadTestingContext context = LoadTestingContext.Create(base.ConnectionStringRepository);

            if (addOrUpdateLoadtestsValidationResult.ValidationComplete)
            {
                if (addOrUpdateLoadtestsValidationResult.ToBeInserted.Any())
                {
                    IEnumerable <LoadtestMongoDb> toBeInserted = addOrUpdateLoadtestsValidationResult.ToBeInserted.PrepareAllForInsertion();
                    context.Loadtests.InsertMany(toBeInserted);
                }

                if (addOrUpdateLoadtestsValidationResult.ToBeUpdated.Any())
                {
                    foreach (Loadtest toBeUpdated in addOrUpdateLoadtestsValidationResult.ToBeUpdated)
                    {
                        Guid            existingLoadtestId = toBeUpdated.Id;
                        var             loadtestInDbQuery  = context.Loadtests.Find <LoadtestMongoDb>(lt => lt.DomainId == existingLoadtestId);
                        LoadtestMongoDb loadtestInDb       = loadtestInDbQuery.SingleOrDefault();
                        loadtestInDb.AgentId        = toBeUpdated.AgentId;
                        loadtestInDb.CustomerId     = toBeUpdated.CustomerId;
                        loadtestInDb.EngineerId     = toBeUpdated.EngineerId;
                        loadtestInDb.LoadtestTypeId = toBeUpdated.LoadtestTypeId;
                        LoadtestParameters ltDomainParameters = toBeUpdated.Parameters;
                        loadtestInDb.Parameters.DurationSec        = ltDomainParameters.DurationSec;
                        loadtestInDb.Parameters.ExpectedEndDateUtc = ltDomainParameters.StartDateUtc.AddSeconds(ltDomainParameters.DurationSec);
                        loadtestInDb.Parameters.StartDateUtc       = ltDomainParameters.StartDateUtc;
                        loadtestInDb.Parameters.UserCount          = ltDomainParameters.UserCount;
                        loadtestInDb.ProjectId  = toBeUpdated.ProjectId;
                        loadtestInDb.ScenarioId = toBeUpdated.ScenarioId;
                        context.Loadtests.FindOneAndReplace <LoadtestMongoDb>(lt => lt.DbObjectId == loadtestInDb.DbObjectId, loadtestInDb);
                    }
                }
            }
            else
            {
                throw new InvalidOperationException("Validation is not complete. You have to call the AddOrUpdateLoadtests method of the Timetable class first.");
            }
        }
コード例 #8
0
        public void DeleteById(Guid guid)
        {
            LoadTestingContext context = LoadTestingContext.Create(base.ConnectionStringRepository);

            context.Loadtests.FindOneAndDelete <LoadtestMongoDb>(lt => lt.DomainId == guid);
        }
コード例 #9
0
        public IList <Loadtest> ConvertToDomain(IEnumerable <LoadtestViewModel> viewModels)
        {
            List <Loadtest>    loadtests = new List <Loadtest>();
            LoadTestingContext context   = LoadTestingContext.Create(base.ConnectionStringRepository);

            foreach (LoadtestViewModel vm in viewModels)
            {
                Guid id = vm.Id;
                LoadtestParameters ltParams = new LoadtestParameters(vm.StartDateUtc, vm.UserCount, vm.DurationSec);

                var          agentQueryBuilder   = Builders <AgentMongoDb> .Filter;
                var          agentCityFilter     = agentQueryBuilder.Eq <string>(a => a.Location.City.ToLower(), vm.AgentCity.ToLower());
                var          agentCountryFilter  = agentQueryBuilder.Eq <string>(a => a.Location.Country.ToLower(), vm.AgentCountry.ToLower());
                var          agentCompleteFilter = agentQueryBuilder.And(agentCityFilter, agentCountryFilter);
                AgentMongoDb agentDb             = context.Agents.Find(agentCompleteFilter).FirstOrDefault();
                if (agentDb == null)
                {
                    throw new ArgumentException("There is no agent with the given properties.");
                }

                var             customerQueryBuilder = Builders <CustomerMongoDb> .Filter;
                var             customerQuery        = customerQueryBuilder.Eq <string>(c => c.Name.ToLower(), vm.CustomerName.ToLower());
                CustomerMongoDb custDb = context.Customers.Find(customerQuery).SingleOrDefault();
                if (custDb == null)
                {
                    throw new ArgumentException("There is no customer with the given properties.");
                }

                Guid?engineerId = null;
                if (!string.IsNullOrEmpty(vm.EngineerName))
                {
                    EngineerMongoDb engDb = context.Engineers.Find(e => e.Name.ToLower() == vm.EngineerName.ToLower()).SingleOrDefault();
                    if (engDb == null)
                    {
                        throw new ArgumentException("There is no engineer with the given properties.");
                    }
                    engineerId = engDb.DomainId;
                }

                LoadtestTypeMongoDb ltTypeDb = context.LoadtestTypes.Find(t => t.Description.ShortDescription.ToLower() == vm.LoadtestTypeShortDescription.ToLower()).SingleOrDefault();
                if (ltTypeDb == null)
                {
                    throw new ArgumentException("There is no load test type with the given properties.");
                }

                ProjectMongoDb projectDb = context.Projects.Find(p => p.Description.ShortDescription.ToLower() == vm.ProjectName.ToLower()).SingleOrDefault();
                if (projectDb == null)
                {
                    throw new ArgumentException("There is no project with the given properties.");
                }

                var             scenarioQueryBuilder   = Builders <ScenarioMongoDb> .Filter;
                var             scenarioUriOneFilter   = scenarioQueryBuilder.Eq <string>(s => s.UriOne.ToLower(), vm.ScenarioUriOne.ToLower());
                var             scenarioUriTwoFilter   = scenarioQueryBuilder.Eq <string>(s => s.UriTwo.ToLower(), vm.ScenarioUriTwo.ToLower());
                var             scenarioUriThreeFilter = scenarioQueryBuilder.Eq <string>(s => s.UriThree.ToLower(), vm.ScenarioUriThree.ToLower());
                var             scenarioCompleteFilter = scenarioQueryBuilder.And(scenarioUriOneFilter, scenarioUriTwoFilter, scenarioUriThreeFilter);
                ScenarioMongoDb scenarioDb             = context.Scenarios.Find(scenarioCompleteFilter).SingleOrDefault();
                if (scenarioDb == null)
                {
                    scenarioDb = new ScenarioMongoDb()
                    {
                        DbObjectId = ObjectId.GenerateNewId(),
                        DomainId   = Guid.NewGuid()
                    };
                    if (!string.IsNullOrEmpty(vm.ScenarioUriOne))
                    {
                        scenarioDb.UriOne = vm.ScenarioUriOne;
                    }
                    if (!string.IsNullOrEmpty(vm.ScenarioUriTwo))
                    {
                        scenarioDb.UriTwo = vm.ScenarioUriTwo;
                    }
                    if (!string.IsNullOrEmpty(vm.ScenarioUriThree))
                    {
                        scenarioDb.UriThree = vm.ScenarioUriThree;
                    }
                    context.Scenarios.InsertOne(scenarioDb);
                }

                Loadtest converted = new Loadtest(id, ltParams, agentDb.DomainId, custDb.DomainId, engineerId, ltTypeDb.DomainId, projectDb.DomainId, scenarioDb.DomainId);
                loadtests.Add(converted);
            }
            return(loadtests);
        }
コード例 #10
0
        public IList <LoadtestViewModel> ConvertToViewModels(IEnumerable <Loadtest> domains)
        {
            List <LoadtestViewModel> viewModels = new List <LoadtestViewModel>();
            LoadTestingContext       context    = LoadTestingContext.Create(base.ConnectionStringRepository);

            foreach (Loadtest lt in domains)
            {
                LoadtestViewModel vm = new LoadtestViewModel();
                vm.Id = lt.Id;
                AgentMongoDb agentDb = context.Agents.Find <AgentMongoDb>(a => a.DomainId == lt.AgentId).SingleOrDefault();
                if (agentDb == null)
                {
                    throw new ArgumentException("There is no load test agent with the given ID.");
                }
                vm.AgentCountry = agentDb.Location.Country;
                vm.AgentCity    = agentDb.Location.City;

                CustomerMongoDb custDb = context.Customers.Find <CustomerMongoDb>(c => c.DomainId == lt.CustomerId).SingleOrDefault();
                if (custDb == null)
                {
                    throw new ArgumentException("There is no customer with the given ID.");
                }
                vm.CustomerName = custDb.Name;

                if (lt.EngineerId.HasValue)
                {
                    EngineerMongoDb engDb = context.Engineers.Find <EngineerMongoDb>(e => e.DomainId == lt.EngineerId.Value).SingleOrDefault();
                    if (engDb == null)
                    {
                        throw new ArgumentException("There is no engineer with the given ID.");
                    }
                    vm.EngineerName = engDb.Name;
                }

                LoadtestTypeMongoDb loadtestTypeDb = context.LoadtestTypes.Find(l => l.DomainId == lt.LoadtestTypeId).SingleOrDefault();
                if (loadtestTypeDb == null)
                {
                    throw new ArgumentException("There is no load test type with the given ID.");
                }
                vm.LoadtestTypeShortDescription = loadtestTypeDb.Description.ShortDescription;

                ProjectMongoDb projectDb = context.Projects.Find(p => p.DomainId == lt.ProjectId).SingleOrDefault();
                if (projectDb == null)
                {
                    throw new ArgumentException("There is no project with the given ID.");
                }
                vm.ProjectName = projectDb.Description.ShortDescription;

                ScenarioMongoDb scenarioDb = context.Scenarios.Find(s => s.DomainId == lt.ScenarioId).SingleOrDefault();
                if (scenarioDb == null)
                {
                    throw new ArgumentException("There is no scenario with the given ID.");
                }
                vm.ScenarioUriOne   = scenarioDb.UriOne;
                vm.ScenarioUriTwo   = scenarioDb.UriTwo;
                vm.ScenarioUriThree = scenarioDb.UriThree;

                vm.UserCount    = lt.Parameters.UserCount;
                vm.StartDateUtc = lt.Parameters.StartDateUtc;
                vm.DurationSec  = lt.Parameters.DurationSec;

                viewModels.Add(vm);
            }
            return(viewModels);
        }
コード例 #11
0
        private static void Seed()
        {
            LoadTestingContext  context = LoadTestingContext.Create(new WebConfigConnectionStringRepository());
            List <AgentMongoDb> agents  = new List <AgentMongoDb>();
            AgentMongoDb        amazon  = new AgentMongoDb();

            amazon.DomainId   = Guid.NewGuid();
            amazon.DbObjectId = ObjectId.GenerateNewId();
            amazon.Location   = new LocationMongoDb()
            {
                City       = "Seattle",
                Country    = "USA",
                DbObjectId = ObjectId.GenerateNewId()
            };
            AgentMongoDb rackspace = new AgentMongoDb();

            rackspace.DomainId   = Guid.NewGuid();
            rackspace.DbObjectId = ObjectId.GenerateNewId();
            rackspace.Location   = new LocationMongoDb()
            {
                City       = "Frankfurt",
                Country    = "Germany",
                DbObjectId = ObjectId.GenerateNewId()
            };
            AgentMongoDb azure = new AgentMongoDb();

            azure.DomainId   = Guid.NewGuid();
            azure.DbObjectId = ObjectId.GenerateNewId();
            azure.Location   = new LocationMongoDb()
            {
                City       = "Tokyo",
                Country    = "Japan",
                DbObjectId = ObjectId.GenerateNewId()
            };
            agents.Add(amazon);
            agents.Add(rackspace);
            agents.Add(azure);
            Task addManyAgentsTask = context.Agents.InsertManyAsync(agents);

            List <CustomerMongoDb> customers    = new List <CustomerMongoDb>();
            CustomerMongoDb        niceCustomer = new CustomerMongoDb();

            niceCustomer.DomainId   = Guid.NewGuid();
            niceCustomer.DbObjectId = ObjectId.GenerateNewId();
            niceCustomer.Name       = "Nice customer";

            CustomerMongoDb greatCustomer = new CustomerMongoDb();

            greatCustomer.DomainId   = Guid.NewGuid();
            greatCustomer.DbObjectId = ObjectId.GenerateNewId();
            greatCustomer.Name       = "Great customer";

            CustomerMongoDb okCustomer = new CustomerMongoDb();

            okCustomer.DomainId   = Guid.NewGuid();
            okCustomer.DbObjectId = ObjectId.GenerateNewId();
            okCustomer.Name       = "OK Customer";

            customers.Add(niceCustomer);
            customers.Add(greatCustomer);
            customers.Add(okCustomer);
            Task addManyCustomersTask = context.Customers.InsertManyAsync(customers);

            List <EngineerMongoDb> engineers = new List <EngineerMongoDb>();
            EngineerMongoDb        john      = new EngineerMongoDb();

            john.DomainId   = Guid.NewGuid();
            john.Name       = "John";
            john.DbObjectId = ObjectId.GenerateNewId();

            EngineerMongoDb mary = new EngineerMongoDb();

            mary.DomainId   = Guid.NewGuid();
            mary.Name       = "Mary";
            mary.DbObjectId = ObjectId.GenerateNewId();

            EngineerMongoDb fred = new EngineerMongoDb();

            fred.DomainId   = Guid.NewGuid();
            fred.Name       = "Fred";
            fred.DbObjectId = ObjectId.GenerateNewId();

            engineers.Add(john);
            engineers.Add(mary);
            engineers.Add(fred);
            Task addManyEngineersTask = context.Engineers.InsertManyAsync(engineers);

            List <LoadtestTypeMongoDb> testTypes  = new List <LoadtestTypeMongoDb>();
            LoadtestTypeMongoDb        stressTest = new LoadtestTypeMongoDb();

            stressTest.DomainId    = Guid.NewGuid();
            stressTest.DbObjectId  = ObjectId.GenerateNewId();
            stressTest.Description = new DescriptionMongoDb()
            {
                DbObjectId       = ObjectId.GenerateNewId(),
                ShortDescription = "Stress test",
                LongDescription  = "To determine or validate an application’s behavior when it is pushed beyond normal or peak load conditions."
            };

            LoadtestTypeMongoDb capacityTest = new LoadtestTypeMongoDb();

            capacityTest.DomainId    = Guid.NewGuid();
            capacityTest.DbObjectId  = ObjectId.GenerateNewId();
            capacityTest.Description = new DescriptionMongoDb()
            {
                DbObjectId       = ObjectId.GenerateNewId(),
                ShortDescription = "Capacity test",
                LongDescription  = "To determine how many users and/or transactions a given system will support and still meet performance goals."
            };

            testTypes.Add(stressTest);
            testTypes.Add(capacityTest);
            Task addManyLoadtestTypesTask = context.LoadtestTypes.InsertManyAsync(testTypes);

            List <ProjectMongoDb> projects     = new List <ProjectMongoDb>();
            ProjectMongoDb        firstProject = new ProjectMongoDb();

            firstProject.DomainId    = Guid.NewGuid();
            firstProject.DbObjectId  = ObjectId.GenerateNewId();
            firstProject.Description = new DescriptionMongoDb()
            {
                DbObjectId       = ObjectId.GenerateNewId(),
                ShortDescription = "First project",
                LongDescription  = "Long description of first project"
            };

            ProjectMongoDb secondProject = new ProjectMongoDb();

            secondProject.DomainId    = Guid.NewGuid();
            secondProject.DbObjectId  = ObjectId.GenerateNewId();
            secondProject.Description = new DescriptionMongoDb()
            {
                DbObjectId       = ObjectId.GenerateNewId(),
                ShortDescription = "Second project",
                LongDescription  = "Long description of second project"
            };

            ProjectMongoDb thirdProject = new ProjectMongoDb();

            thirdProject.DomainId    = Guid.NewGuid();
            thirdProject.DbObjectId  = ObjectId.GenerateNewId();
            thirdProject.Description = new DescriptionMongoDb()
            {
                DbObjectId       = ObjectId.GenerateNewId(),
                ShortDescription = "Third project",
                LongDescription  = "Long description of third project"
            };
            projects.Add(firstProject);
            projects.Add(secondProject);
            projects.Add(thirdProject);
            Task addManyProjectsTask = context.Projects.InsertManyAsync(projects);

            List <ScenarioMongoDb> scenarios   = new List <ScenarioMongoDb>();
            ScenarioMongoDb        scenarioOne = new ScenarioMongoDb();

            scenarioOne.DomainId   = Guid.NewGuid();
            scenarioOne.DbObjectId = ObjectId.GenerateNewId();
            scenarioOne.UriOne     = "www.bbc.co.uk";
            scenarioOne.UriTwo     = "www.cnn.com";

            ScenarioMongoDb scenarioTwo = new ScenarioMongoDb();

            scenarioTwo.DomainId   = Guid.NewGuid();
            scenarioTwo.DbObjectId = ObjectId.GenerateNewId();
            scenarioTwo.UriOne     = "www.amazon.com";
            scenarioTwo.UriTwo     = "www.microsoft.com";

            ScenarioMongoDb scenarioThree = new ScenarioMongoDb();

            scenarioThree.DomainId   = Guid.NewGuid();
            scenarioThree.DbObjectId = ObjectId.GenerateNewId();
            scenarioThree.UriOne     = "www.greatsite.com";
            scenarioThree.UriTwo     = "www.nosuchsite.com";
            scenarioThree.UriThree   = "www.neverheardofsite.com";

            scenarios.Add(scenarioOne);
            scenarios.Add(scenarioTwo);
            scenarios.Add(scenarioThree);
            Task addManyScenariosTask = context.Scenarios.InsertManyAsync(scenarios);

            List <LoadtestMongoDb> loadtests = new List <LoadtestMongoDb>();
            LoadtestMongoDb        ltOne     = new LoadtestMongoDb();

            ltOne.DomainId       = Guid.NewGuid();
            ltOne.DbObjectId     = ObjectId.GenerateNewId();
            ltOne.AgentId        = amazon.DomainId;
            ltOne.CustomerId     = niceCustomer.DomainId;
            ltOne.EngineerId     = john.DomainId;
            ltOne.LoadtestTypeId = stressTest.DomainId;
            DateTime ltOneStart = DateTime.UtcNow;

            ltOne.Parameters = new LoadtestParametersMongoDb()
            {
                DbObjectId         = ObjectId.GenerateNewId(),
                DurationSec        = 60,
                StartDateUtc       = ltOneStart,
                UserCount          = 10,
                ExpectedEndDateUtc = ltOneStart.AddSeconds(60)
            };
            ltOne.ProjectId  = firstProject.DomainId;
            ltOne.ScenarioId = scenarioOne.DomainId;

            LoadtestMongoDb ltTwo = new LoadtestMongoDb();

            ltTwo.DomainId       = Guid.NewGuid();
            ltTwo.DbObjectId     = ObjectId.GenerateNewId();
            ltTwo.AgentId        = azure.DomainId;
            ltTwo.CustomerId     = greatCustomer.DomainId;
            ltTwo.EngineerId     = mary.DomainId;
            ltTwo.LoadtestTypeId = capacityTest.DomainId;
            DateTime ltTwoStart = DateTime.UtcNow.AddMinutes(20);

            ltTwo.Parameters = new LoadtestParametersMongoDb()
            {
                DbObjectId         = ObjectId.GenerateNewId(),
                DurationSec        = 120,
                StartDateUtc       = ltTwoStart,
                UserCount          = 40,
                ExpectedEndDateUtc = ltTwoStart.AddSeconds(120)
            };
            ltTwo.ProjectId  = secondProject.DomainId;
            ltTwo.ScenarioId = scenarioThree.DomainId;

            LoadtestMongoDb ltThree = new LoadtestMongoDb();

            ltThree.DomainId       = Guid.NewGuid();
            ltThree.DbObjectId     = ObjectId.GenerateNewId();
            ltThree.AgentId        = rackspace.DomainId;
            ltThree.CustomerId     = okCustomer.DomainId;
            ltThree.EngineerId     = fred.DomainId;
            ltThree.LoadtestTypeId = stressTest.DomainId;
            DateTime ltThreeStart = DateTime.UtcNow.AddMinutes(30);

            ltThree.Parameters = new LoadtestParametersMongoDb()
            {
                DbObjectId         = ObjectId.GenerateNewId(),
                DurationSec        = 180,
                StartDateUtc       = ltThreeStart,
                UserCount          = 50,
                ExpectedEndDateUtc = ltThreeStart.AddSeconds(180)
            };
            ltThree.ProjectId  = thirdProject.DomainId;
            ltThree.ScenarioId = scenarioTwo.DomainId;

            loadtests.Add(ltOne);
            loadtests.Add(ltTwo);
            loadtests.Add(ltThree);
            Task addManyLoadtestsTask = context.Loadtests.InsertManyAsync(loadtests);

            Task.WaitAll(addManyAgentsTask, addManyCustomersTask, addManyEngineersTask, addManyLoadtestTypesTask
                         , addManyProjectsTask, addManyScenariosTask, addManyLoadtestsTask);
        }