public async Task Update_Driver() { var driver = new Driver { FirstName = "João", LastName = "Das Neves", Car = new Car { Brand = "Porsche", Model = "911 Carrera 2016", Plate = "CPW-8821" }, Address = new Address { Street = "Alameda Santos", Number = "1235", City = "São Paulo", State = "SP", ZipCode = "01419-002" } }; var driverService = new DriverService(new DriverRepository(), new MapsServiceMock()); var driverLast = driverService.GetAll(false, false).LastOrDefault(); driver.Id = driverLast.Id; await driverService.Update(driverLast.Id, driver); var driverRetrived = driverService.Get(driverLast.Id); Assert.Equal(driverLast.Id, driverRetrived.Id); Assert.Equal(driver.FirstName, driverRetrived.FirstName); }
public override bool Arrange() { Service = new DriverService(TestConstants.Configuration); Input = new DriverGetInput(Guid.Empty); return(true); }
public async Task Create_Driver() { var driver = new Driver { FirstName = "Lucas", LastName = "Rocha", Car = new Car { Brand = "Volkswagen", Model = "Gol 2013 1.0", Plate = "PWC-8874" }, Address = new Address { Street = "Rua Pamplona", Number = "976", City = "São Paulo", State = "SP", ZipCode = "01405-200" } }; var driverService = new DriverService(new DriverRepository(), new MapsServiceMock()); await driverService.Insert(driver); var driverRetrived = driverService.Get(driver.Id); Assert.Equal(driver.Id, driverRetrived.Id); Assert.Equal(driver.FirstName, driverRetrived.FirstName); Assert.Equal(driver.Address.MapsLatitude, driverRetrived.Address.MapsLatitude); }
public bool UpdateDriverService(DriverService driverService) { var result = false; try { using (var con = new SqlConnection(ConnString)) { con.Open(); using (var cmd = GenerateDriverServiceSqlCommand("Driver_UpdateDriverService", driverService, con)) { cmd.Parameters.RemoveAt("@driverUserID"); cmd.Parameters.RemoveAt("@latitude"); cmd.Parameters.RemoveAt("@longitude"); cmd.Parameters.Add(new SqlParameter("@driverServiceID", driverService.Activity.Id)); cmd.Parameters.Add(new SqlParameter("idAddress", driverService.Address.Id)); var updatedRecords = cmd.ExecuteNonQuery(); if (updatedRecords == 2) { result = true; } } } } catch (Exception E) { Debug.WriteLine(E.Message); throw new Exception("UpdateDriverService", E); } return(result); }
private SqlCommand GenerateDriverServiceSqlCommand(string sqlCommand, DriverService driverService, SqlConnection con) { var command = new SqlCommand(sqlCommand, con) { CommandType = CommandType.StoredProcedure }; SqlParameter[] sqlParameters = { new SqlParameter("@driverUserID", driverService.Activity.UserId), new SqlParameter("@restaurant", driverService.Activity.Restaurant), new SqlParameter("@pickupQuantity", driverService.PickupQuantity), new SqlParameter("@deliveringTime", driverService.DeliveringTimeStart), new SqlParameter("@notes", driverService.Activity.Notes), new SqlParameter("@address1", driverService.Address.Address1), new SqlParameter("@address2", driverService.Address.Address2), new SqlParameter("@city", driverService.Address.City), new SqlParameter("@state", driverService.Address.State), new SqlParameter("@zipcode", driverService.Address.Zipcode), new SqlParameter("@latitude", 0.00), new SqlParameter("@longitude", 0.00) }; command.Parameters.AddRange(sqlParameters); return(command); }
/// <summary> /// Creates a default instance of the ChromeDriverService. /// </summary> /// <returns>A ChromeDriverService that implements default settings.</returns> public static ChromeDriverService CreateDefaultService() { string serviceDirectory = DriverService.FindDriverServiceExecutable(ChromiumDriverServiceFileName(DefaultChromeDriverServiceExecutableName), ChromeDriverDownloadUrl); return(CreateDefaultService(serviceDirectory)); }
public IHttpActionResult GetByBoatType(BoatType boatType) { DriverService driverService = CreateDriverService(); var drivers = driverService.GetDriversByBoatType(boatType); return(Ok(drivers)); }
public void CreateDriver() { _mockAssemblyPath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, MOCK_ASSEMBLY); var service = new DriverService(); _driver = service.GetDriver(_mockAssemblyPath, true); }
public ActionResult CreateOrUpdate(string id, int?type) { DriverIndexViewModel vi = new DriverIndexViewModel(); if (string.IsNullOrEmpty(id)) { Driver v = new Driver(); v.Str1 = Guid.NewGuid().ToString(); v.Str2 = Guid.NewGuid().ToString(); v.Str3 = Guid.NewGuid().ToString(); v.Str4 = Guid.NewGuid().ToString(); v.DriverIsServing = true; vi.Driver = v; vi.ViewType = 0; } else { if (type == 1) { var response = new DriverService().GetSearcheDriver(id); vi.Driver = response; vi.ViewType = 1; } else { var response = new DriverService().GetSearcheDriver(id); vi.Driver = response; vi.ViewType = 0; } } return(View(vi)); }
public async Task <ActionResult> GetShipperMappingDriverInfoBySIDandkeyWord(string id, string keyword, int?pageIndex) { return(await Task.Run <ActionResult>(() => { var getCRMDriverByConditionRequest = new GetDriverByConditionRequest(); getCRMDriverByConditionRequest.SearchCondition = new DriverSearchCondition(); getCRMDriverByConditionRequest.keyword = keyword; getCRMDriverByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE; getCRMDriverByConditionRequest.PageIndex = pageIndex ?? 0; DriverViewModel vm = new DriverViewModel(); var getCRMDriverByConditionResponse = new DriverService().GetShipperMappingDriverInfoBySIDandkeyWord(id, getCRMDriverByConditionRequest); if (getCRMDriverByConditionResponse.IsSuccess) { vm.DriverCollection = getCRMDriverByConditionResponse.Result.DriverCollection; vm.PageIndex = getCRMDriverByConditionResponse.Result.PageIndex; vm.PageCount = getCRMDriverByConditionResponse.Result.PageCount; } else { throw new Exception(getCRMDriverByConditionResponse.Exception.Message); } JavaScriptSerializer serializer = new JavaScriptSerializer(); serializer.RegisterConverters(new JavaScriptConverter[] { new DateTimeConverter() }); string js = serializer.Serialize(vm); return Json(js, JsonRequestBehavior.AllowGet); })); }
/// <summary> /// 通过shipperID查询该车辆是由哪位司机驾驶 /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <ActionResult> ShipperMappingDriverBySID(int id) { return(await Task.Run <ActionResult>(() => { var getCRMVehicleByConditionRequest = new GetDriverByConditionRequest(); getCRMVehicleByConditionRequest.SearchCondition = new DriverSearchCondition(); getCRMVehicleByConditionRequest.keyword = id.ToString(); getCRMVehicleByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE; getCRMVehicleByConditionRequest.PageIndex = 0; DriverViewModel vm = new DriverViewModel(); var getCRMDriverByConditionResponse = new DriverService().GetShippingMappingDriverSID(getCRMVehicleByConditionRequest); if (getCRMDriverByConditionResponse.IsSuccess) { vm.DriverCollection = getCRMDriverByConditionResponse.Result.DriverCollection; vm.PageIndex = getCRMDriverByConditionResponse.Result.PageIndex; vm.PageCount = getCRMDriverByConditionResponse.Result.PageCount; } else { throw new Exception(getCRMDriverByConditionResponse.Exception.Message); } ViewData["id"] = id; return View(vm); })); }
public static async Task <string> UpdateDriver(Driver driver) { var driverService = new DriverService(); var response = await driverService.UpdateDriver(driver); return(response.ToString()); }
private void runAutomatedButton_Click(object sender, EventArgs e) { _service = ChromeDriverService.CreateDefaultService(); //_service.LogPath = GetLogFilePath(); //AddMessage($"LogFilePath set to {_service.LogPath}"); //_service.EnableVerboseLogging = true; IWebDriver driver = null; try { //_service.Start(); driver = CreateDriver(); OutputFilePaths.ForEach(f => AutoProcessFile(driver, f)); } catch (Exception ex) { AddMessage($"Exception: {ex.Message}"); } finally { if (driver != null) { driver.Quit(); driver.Dispose(); } //_service.Dispose(); } }
public async Task <ActionResult> Driver() { return(await Task.Run <ActionResult>(() => { var getCRMDriverByConditionRequest = new GetDriverByConditionRequest(); getCRMDriverByConditionRequest.SearchCondition = new DriverSearchCondition(); getCRMDriverByConditionRequest.PageSize = BasicFramework.Common.Constants.PAGESIZE; getCRMDriverByConditionRequest.PageIndex = 0; DriverViewModel vm = new DriverViewModel(); var getCRMDriverByConditionResponse = new DriverService().GetCRMDriverBykeyword(getCRMDriverByConditionRequest); if (getCRMDriverByConditionResponse.IsSuccess) { vm.DriverCollection = getCRMDriverByConditionResponse.Result.DriverCollection; vm.PageIndex = getCRMDriverByConditionResponse.Result.PageIndex; vm.PageCount = getCRMDriverByConditionResponse.Result.PageCount; } else { throw new Exception(getCRMDriverByConditionResponse.Exception.Message); } return View(vm); })); }
public ActionResult VehicleDriverMapping(string id) { VehicleDriverMappingViewModel vd = new VehicleDriverMappingViewModel(); var vehicle = ApplicationConfigHelper.GetVehicleList().FirstOrDefault(m => m.ID.ToString() == id); vd.VID = vehicle.ID; vd.VehicleNo = vehicle.CarNo; //var driver = ApplicationConfigHelper.GetDriverList(); DriverSearchCondition ds = new DriverSearchCondition(); ds.VehicleID = id; //int pagesize = 17; var response = new DriverService().GetAllDriver(new GetDriverByConditionRequest() { SearchCondition = ds, PageIndex = vd.PageIndex, PageSize = UtilConstants.PAGESIZE, }); if (response.IsSuccess) { vd.Driver = response.Result.DriverCollection; vd.PageIndex = response.Result.PageIndex; vd.PageCount = response.Result.PageCount; } return(View(vd)); }
/// <summary> /// This allows all of the drivers to be retreived /// </summary> /// <returns>This returns all of the drivers</returns> public IHttpActionResult Get() { DriverService driverService = CreateDriverService(); var drivers = driverService.GetDrivers(); return(Ok(drivers)); }
public IHttpActionResult Get(int id) { DriverService driverService = CreateDriverService(); var driver = driverService.GetDriverById(id); return(Ok(driver)); }
public IHttpActionResult GetByDaysAvailable(DaysOfWeek daysOfWeek) { DriverService driverService = CreateDriverService(); var drivers = driverService.GetDriversByDaysAvailable(daysOfWeek); return(Ok(drivers)); }
private DriverService CreateDriverService() { var userId = Guid.Parse(User.Identity.GetUserId()); var driverService = new DriverService(userId); return(driverService); }
public async Task EditAsync_ShouldSuccessfullyEdit() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var driverService = new DriverService(context); var editDriverServiceModel = new EditDriverServiceModel(); var driverId = 1; var driverFullName = "DFN 3"; editDriverServiceModel.Id = driverId; editDriverServiceModel.FullName = driverFullName; await driverService.EditAsync(editDriverServiceModel); var expectedResult = driverFullName; var actualResult = driverService .All() .First() .FullName; Assert.True(expectedResult == actualResult); }
public async Task DeleteByIdAsync_ShouldSuccessfullyDelete() { MapperInitializer.InitializeMapper(); var context = ApplicationDbContextInMemoryFactory.InitializeContext(); await this.SeedDataAsync(context); var driverService = new DriverService(context); var deleteDriverServiceModel = new DeleteDriverServiceModel(); deleteDriverServiceModel.Id = 1; await driverService.DeleteByIdAsync(deleteDriverServiceModel.Id); var expectedResult = 1; var actualResult = driverService .All() .Count(); var expectedResult2 = "DFN 2"; var actualResult2 = driverService .All() .First() .FullName; Assert.True(expectedResult == actualResult); Assert.True(expectedResult2 == actualResult2); }
public FakeIEDriver(DriverService service, InternetExplorerOptions options, TimeSpan commandTimeout) { Console.WriteLine("svc opt span2"); UnitTestReport = //IEDriverConstructorOptions.ie_with_service_and_options_and_timespan.ToString(); DriverServerConstructorOptions.WithServiceAndOptionsAndTimespan.ToString(); }
/// <summary> /// Load a TestPackage for exploration or execution /// </summary> /// <returns>A TestEngineResult.</returns> protected override TestEngineResult LoadPackage() { var result = new TestEngineResult(); // DirectRunner may be called with a single-assembly package // or a set of assemblies as subpackages. var packages = TestPackage.SubPackages; if (packages.Count == 0) { packages.Add(TestPackage); } var driverService = new DriverService(); foreach (var subPackage in packages) { var testFile = subPackage.FullName; bool skipNonTestAssemblies = subPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false); IFrameworkDriver driver = driverService.GetDriver(testFile, skipNonTestAssemblies); driver.ID = TestPackage.ID; result.Add(driver.Load(testFile, subPackage.Settings)); _drivers.Add(driver); } return(result); }
public IHttpActionResult GetByLocation(string location) { DriverService driverService = CreateDriverService(); var drivers = driverService.GetDriversByLocation(location); return(Ok(drivers)); }
/// <summary> /// Creates a default instance of the EdgeDriverService. /// </summary> /// <returns>A EdgeDriverService that implements default settings.</returns> public static EdgeDriverService CreateDefaultService() { string serviceDirectory = DriverService.FindDriverServiceExecutable(MicrosoftWebDriverServiceFileName, MicrosoftWebDriverDownloadUrl); EdgeDriverService service = CreateDefaultService(serviceDirectory); return(service); }
public IHttpActionResult GetByMaxOccupants(int occupancy) { DriverService driverService = CreateDriverService(); var drivers = driverService.GetDriversByOccupancy(occupancy); return(Ok(drivers)); }
public void SupplyingAcceptableCapabilitiesForDriverServiceLaunchesChromeBrowser() { TestEnvironmentParameters @params = new TestEnvironmentParameters() { RS_LocalExecution = true, RS_LocalExecutionAsService = true, RS_DriverServerExePath = TestContext.CurrentContext.TestDirectory, RS_BrowserName = "chrome", RS_ServerHost = "localhost", RS_ServerPort = "4278", RS_ImplicitWaitTime = "0" //Write unit test for testing empty properties }; DriverService.Start(@params); DriverCapabilities caps = new DriverCapabilities(@params); caps.GetDriverOptions <ChromeOptions>().AddArgument("--headless"); //Test this in unit test WebDriver.Initialize(caps); Assert.That(WebDriver.Instance != null, "Driver should have been instantiated successfully"); Assert.AreEqual("data:,", WebDriver.Instance.Url, "Empty url should have been opened"); WebDriver.Instance.Navigate().GoToUrl("https://google.com"); Assert.AreEqual("https://www.google.com/", WebDriver.Instance.Url, "Should have navigated to google.com"); WebDriver.Dispose(); DriverService.Dispose(); }
private void SetWebDriverToChrome() { var driverExePath = _driverPaths + "chrome" + Path.DirectorySeparatorChar + _chromedriver; _driverservice = ChromeDriverService.CreateDefaultService(driverExePath); var settings = new ChromeOptions { BinaryLocation = "", LeaveBrowserRunning = true }; try { _driverservice.Start(); } catch (Exception err) { throw new DriverServiceNotFoundException(err.Message); } _capabilities = DesiredCapabilities.Chrome(); SetAdditionalCapabilities(); WebDriver = new ScreenShotRemoteWebDriver(_driverservice.ServiceUrl, _capabilities); }
public static async Task <string> DeleteDriver(int id) { var driverService = new DriverService(); var response = await driverService.DeleteDriver(id); return(response.ToString()); }
private void SetWebDriverToIE() { var driverExePath = _driverPaths + "ie" + Path.DirectorySeparatorChar + _ieDriverServer; _driverservice = InternetExplorerDriverService.CreateDefaultService(driverExePath); var settings = new InternetExplorerOptions { IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnsureCleanSession = true }; try { _driverservice.Start(); } catch (Exception err) { throw new DriverServiceNotFoundException(err.Message); } _capabilities = DesiredCapabilities.InternetExplorer(); SetAdditionalCapabilities(); WebDriver = new ScreenShotRemoteWebDriver(_driverservice.ServiceUrl, _capabilities); }
public void CreateDriverFactory() { var serviceContext = new ServiceContext(); serviceContext.Add(new ExtensionService()); _driverService = new DriverService(); serviceContext.Add(_driverService); serviceContext.ServiceManager.StartServices(); }
public void CreateDriverFactory() { _service = new DriverService(); _service.StartService(); }
/// <summary> /// Initializes a new instance of the InternetExplorerDriver class using the specified <see cref="DriverService"/>. /// </summary> /// <param name="service">The <see cref="DriverService"/> to use.</param> /// <param name="options">The <see cref="InternetExplorerOptions"/> used to initialize the driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public InternetExplorerDriver(DriverService service, InternetExplorerOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout), options.ToCapabilities()) { }
private static Uri GetDriverServiceUrl(DriverService driverService) { Uri driverUrl = null; if (driverService != null) { driverUrl = driverService.ServiceUrl; } return driverUrl; }
/// <summary> /// Initializes a new instance of the ChromeDriver class using the specified <see cref="ChromeDriverService"/>. /// </summary> /// <param name="service">The <see cref="ChromeDriverService"/> to use.</param> /// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> private ChromeDriver(DriverService service, ChromeOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout), options.ToCapabilities()) { }
/// <summary> /// Initializes a new instance of the <see cref="DriverServiceCommandExecutor"/> class. /// </summary> /// <param name="driverService">The <see cref="DriverService"/> that drives the browser.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout) : this(driverService, commandTimeout, true) { }
/// <summary> /// Initializes a new instance of the <see cref="DriverServiceCommandExecutor"/> class. /// </summary> /// <param name="driverService">The <see cref="DriverService"/> that drives the browser.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> /// <param name="enableKeepAlive"><see langword="true"/> if the KeepAlive header should be sent /// with HTTP requests; otherwise, <see langword="false"/>.</param> public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout, bool enableKeepAlive) { this.service = driverService; this.internalExecutor = new HttpCommandExecutor(driverService.ServiceUrl, commandTimeout, enableKeepAlive); }
/// <summary> /// Initializes a new instance of the PhantomJSDriver class using the specified <see cref="DriverService"/>. /// </summary> /// <param name="service">The <see cref="DriverService"/> to use.</param> /// <param name="options">The <see cref="PhantomJSOptions"/> used to initialize the driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public PhantomJSDriver(DriverService service, PhantomJSOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout, false), options.ToCapabilities()) { }
/// <summary> /// Initializes a new instance of the <see cref="DriverServiceCommandExecutor"/> class. /// </summary> /// <param name="driverService">The <see cref="DriverService"/> that drives the browser.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout) : base(GetDriverServiceUrl(driverService), commandTimeout) { this.service = driverService; }
/// <summary> /// Initializes a new instance of the <see cref="DriverServiceCommandExecutor"/> class. /// </summary> /// <param name="driverService">The <see cref="DriverService"/> that drives the browser.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> /// <param name="enableKeepAlive"><see langword="true"/> if the KeepAlive header should be sent /// with HTTP requests; otherwise, <see langword="false"/>.</param> public DriverServiceCommandExecutor(DriverService driverService, TimeSpan commandTimeout, bool enableKeepAlive) : base(GetDriverServiceUrl(driverService), commandTimeout, enableKeepAlive) { this.service = driverService; }