public void Initialize() { driver = new FirefoxDriver(); js = (IJavaScriptExecutor)driver; context = new ScrapeCityDbContext(); helper = new AddMonitorHelper(); }
public void EditItem(int Id) { using (var context = new ScrapeCityDbContext()) { _index.SaveObject(JObject.Parse(JsonConvert.SerializeObject(context.Monitors.Find(Id), Formatting.Indented, converters: new Newtonsoft.Json.Converters.StringEnumConverter()))); } }
public void WipeAndCreateDatabase() { // drop database first ReallyDropDatabase(ConnectionString); // Now time to create the database from migrations // MyApp.Data.Migrations.Configuration is migration configuration class // this class is crated for you automatically when you enable migrations var initializer = new MigrateDatabaseToLatestVersion <ScrapeCityDbContext, ScrapeCity.Data.Migrations.Configuration>(); // set DB initialiser to execute migrations Database.SetInitializer(initializer); // now actually force the initialisation to happen using (var context = new ScrapeCityDbContext()) { context.Database.Initialize(true); } // And after the DB is created, you can put some initial base data // for your tests to use //using (var context = new ScrapeCityDbContext(/*connectionString*/)) //{ // SeedContextForTests(context); //} }
public void Initialize() { driver = new FirefoxDriver(); driver.Manage().Timeouts().ImplicitWait = new TimeSpan(0, 0, 3); context = new ScrapeCityDbContext(); helper = new EditMonitorHelper(); }
public void UpdateMonitorIndex() { _index.ClearIndex(); using (var context = new ScrapeCityDbContext()) { var monitors = context.Monitors.ToList(); foreach (var monitor in monitors) { _index.AddObject(JObject.Parse(JsonConvert.SerializeObject(monitor, Formatting.Indented, converters: new Newtonsoft.Json.Converters.StringEnumConverter()))); } } }
public void Initialize() { driver = new FirefoxDriver(); context = new ScrapeCityDbContext(); helper = new EditMonitorHelper(); }
//TODO resolve dependancy public AbstractService() { this.context = new ScrapeCityDbContext(); }
public override void Up() { var monitorUploadPath = Settings.ImagesServerUploadPath + "Monitor\\"; using (var context = new ScrapeCityDbContext()) { //this is not selecting the whole model because of forward compatability. // Ex. : if you add a new property and select the whole obj. when you have to run more than 1 migration // this one will fail because it cannot select the new properties as they're not in the DB var monitors = context.Monitors.Select(x => new { x.Id, MonitorPictures = x.MonitorImages.ToList(), x.Brand.BrandName, x.Model, x.Thumbnail }).ToList(); foreach (var monitor in monitors) { var images = monitor.MonitorPictures; foreach (var image in images) { var oldFileRelativePath = image.Uri; var oldFileName = oldFileRelativePath.Substring(oldFileRelativePath.LastIndexOf("/") + 1); var fileName = Guid.NewGuid().ToString() + ".jpg"; string hdddir = ""; if (Path.IsPathRooted(monitorUploadPath)) { hdddir = Path.Combine(monitorUploadPath, monitor.BrandName, monitor.Model); } else { hdddir = Path.Combine(HttpRuntime.AppDomainAppPath, monitorUploadPath, monitor.BrandName, monitor.Model); } var oldHddDir = Path.Combine(hdddir, oldFileName); var newHddDir = Path.Combine(hdddir, fileName); try { System.IO.File.Move(oldHddDir, newHddDir); } catch (Exception) { } var imageUrlPath = $@"/{monitor.BrandName}/{monitor.Model}/{fileName}"; if (monitor.Thumbnail != "/placeholder.jpg") { if (monitor.Thumbnail == image.Uri) { // Since we can't get the whole model, we have to update just the thumbnail, manually. context.Database.ExecuteSqlCommand("UPDATE dbo.Monitors SET Thumbnail = @Thumbnail WHERE Id = @Id", new SqlParameter("Thumbnail", imageUrlPath), new SqlParameter("Id", monitor.Id)); } } image.Uri = imageUrlPath; } context.SaveChanges(); } } }
public void Initialize() { driver = new FirefoxDriver(); context = new ScrapeCityDbContext(); }