public void TestOrderViews_ShouldRenderProjectLocationValidationMessageBeforeSubmitOrder() { ShipToAddressViewModel ShipToAddressModel = _projectServiceLight.GetProjectLocation(user, _projectId).Model as ShipToAddressViewModel; _driver.Navigate().GoToUrl(@"http://tstsysdcity2/projectdashboard/OrderForm/" + _projectId + "/" + _quoteId + "#!/"); Thread.Sleep(25000);//This is make sure we completed load the form before we manipulate DOM IWebElement submitBtn = _driver.FindElement(By.Id("OrderFormSubmitBtn")); ShipToAddressModel.ShipToName = null; if (submitBtn.Displayed && submitBtn.Enabled) { submitBtn.Click(); if (ShipToAddressModel.ShipToName == string.Empty || ShipToAddressModel.ShipToName == null) { IWebElement projectLocationDiv = _driver.FindElement(By.Id("projectLocationDiv")); IReadOnlyCollection <IWebElement> projectDetailsLists = projectLocationDiv.FindElements(By.TagName("li")); foreach (var item in projectDetailsLists) { Assert.That(item.Text.Contains("Business Name is required"), Is.EqualTo(true)); break; } } } }
public static async Task <WSShipToAddressNAV.Create_Result> CreateAsync(ShipToAddressViewModel shipToAddress, NAVWSConfigurations WSConfigurations) { if (shipToAddress == null) { throw new ArgumentNullException("shipToAddress"); } WSShipToAddressNAV.Create navCreate = new WSShipToAddressNAV.Create() { WSShipToAddress = MapShipToAddressNAV(shipToAddress) }; //Configure NAV Client EndpointAddress ws_URL = new EndpointAddress(WSConfigurations.WS_ShipToAddress_URL.Replace("Company", WSConfigurations.WS_User_Company)); WSShipToAddressNAV.WSShipToAddress_PortClient WS_ShipToAddress = new WSShipToAddressNAV.WSShipToAddress_PortClient(navWSBinding, ws_URL); WS_ShipToAddress.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Delegation; WS_ShipToAddress.ClientCredentials.Windows.ClientCredential = new NetworkCredential(WSConfigurations.WS_User_Login, WSConfigurations.WS_User_Password, WSConfigurations.WS_User_Domain); try { navCreate.WSShipToAddress.Utilizador_Alteracao_eSUCH = shipToAddress.Utilizador_Alteracao_eSUCH; WSShipToAddressNAV.Create_Result result = await WS_ShipToAddress.CreateAsync(navCreate); return(result); } catch (Exception ex) { throw; } }
public JsonResult Delete([FromBody] ShipToAddressViewModel data) { if (data != null) { var deleteTask = WSShipToAddressService.DeleteAsync(data.Customer_No, data.Code, _configws); try { deleteTask.Wait(); } catch (Exception ex) { return(Json(new ErrorHandler() { eReasonCode = 3, eMessage = "Ocorreu um erro a apagar a linha." })); } return(Json(new ErrorHandler() { eReasonCode = 0, eMessage = "Linha removida com sucesso." })); } return(Json(false)); }
public static WSShipToAddressNAV.WSShipToAddress MapShipToAddressNAV(ShipToAddressViewModel ShipToAddressModel) { var mapper = new MapperConfiguration(cfg => cfg.CreateMap <ShipToAddressViewModel, WSShipToAddressNAV.WSShipToAddress>()/*.ForMember(x => x.No, opt => opt.Ignore())*/ ).CreateMapper(); var ShipToAddressNAV = mapper.Map <ShipToAddressViewModel, WSShipToAddressNAV.WSShipToAddress>(ShipToAddressModel); return(ShipToAddressNAV); }
public void TestProjectAPI_GetProjectLocation_shouldReturnShipToLocation() { SetupProjectAPIForTesting(); serviceResponse = projectApi.GetProjectLocation(projectId); ShipToAddressViewModel model = serviceResponse.Model as ShipToAddressViewModel; Address shipLocation = this.db.Context.Addresses.Where(add => add.AddressId == model.AddressId).FirstOrDefault(); Assert.That(serviceResponse.HasError, Is.EqualTo(false)); Assert.That(model.AddressId, Is.EqualTo(shipLocation.AddressId)); Assert.That(model.AddressLine1, Is.EqualTo(shipLocation.AddressLine1)); Assert.That(model.Location, Is.EqualTo(shipLocation.Location)); Assert.That(model.StateId, Is.EqualTo(shipLocation.StateId)); }
public JsonResult Create([FromBody] ShipToAddressViewModel data) { if (data != null) { //data.Country_Region_Code = null; data.Utilizador_Alteracao_eSUCH = User.Identity.Name; var createTask = WSShipToAddressService.CreateAsync(data, _configws); try { createTask.Wait(); } catch (Exception ex) { data.eReasonCode = 3; data.eMessage = "Ocorreu um erro ao criar a linha no NAV."; data.eMessages.Add(new TraceInformation(TraceType.Error, ex.Message)); return(Json(data)); } var result = createTask.Result; if (result == null) { data.eReasonCode = 3; data.eMessage = "Ocorreu um erro ao criar a linha no NAV."; return(Json(data)); } data.eReasonCode = 1; var ShipToAddress = WSShipToAddressService.MapShipToAddressViewModel(result.WSShipToAddress); if (ShipToAddress != null) { ShipToAddress.eReasonCode = 1; return(Json(ShipToAddress)); } } return(Json(data)); }
public void TestOrderViews_ShouldRenderProjectLocationEdit() { ShipToAddressViewModel ShipToAddressModel = _projectServiceLight.GetProjectLocation(user, _projectId).Model as ShipToAddressViewModel; string state = this.db.Context.States.Where(s => s.StateId == ShipToAddressModel.StateId).Select(s => s.Name).FirstOrDefault(); _driver.Navigate().GoToUrl(@"http://tstsysdcity2/projectdashboard/OrderForm/" + _projectId + "/" + _quoteId + "#!/"); Thread.Sleep(25000);//This is make sure we completed load the form before we manipulate DOM ReadOnlyCollection <IWebElement> projectLocationFields = _driver .FindElements(By.ClassName("ProjectLocationfields")); List <string> values = new List <string>(); foreach (var item in projectLocationFields) { IWebElement child = item; if (child.GetAttribute("value") != string.Empty) { values.Add(child.GetAttribute("value")); } } if (values.Count() > 1) { for (int a = 0; a < values.Count; a++) { if (a != values.Count() - 1) { Assert.That(values[a], Is.Not.EqualTo(null)); } } for (int i = 0; i < values.Count(); i++) { switch (i) { case 0: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.ShipToName)); break; case 1: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.CountryCode)); break; case 2: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.AddressLine1)); break; case 3: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.Location)); break; case 4: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.StateId.ToString())); break; case 5: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.PostalCode.ToString())); break; case 6: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.SquareFootage.ToString())); break; case 7: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.NumberOfFloor.ToString())); break; } } //check for Cancel and Submit button visible Assert.That(_driver.FindElement(By.ClassName("submit")).Displayed, Is.EqualTo(true)); Assert.That(_driver.FindElement(By.ClassName("btn-default")).Displayed, Is.EqualTo(true)); //Check for Cancel and Submit button State Assert.That(_driver.FindElement(By.ClassName("submit")).Enabled, Is.EqualTo(true)); Assert.That(_driver.FindElement(By.ClassName("btn-default")).Enabled, Is.EqualTo(true)); } }
public void TestOrderViews_ShouldRenderProjectLocation() { ShipToAddressViewModel ShipToAddressModel = _projectServiceLight.GetProjectLocation(user, _projectId).Model as ShipToAddressViewModel; string state = this.db.Context.States.Where(s => s.StateId == ShipToAddressModel.StateId).Select(s => s.Name).FirstOrDefault(); _driver.Navigate().GoToUrl(@"http://tstsysdcity2/projectdashboard/OrderForm/" + _projectId + "/" + _quoteId + "#!/"); Thread.Sleep(25000);//This is make sure we completed load the form before we manipulate DOM ReadOnlyCollection <IWebElement> projectLocationLists = _driver .FindElement(By.Id("projectLocationDiv")) .FindElements(By.ClassName("details-list")); ReadOnlyCollection <IWebElement> projectLocationList1 = projectLocationLists[0] .FindElement(By.TagName("ul")) .FindElements(By.TagName("li")); List <string> values = new List <string>(); foreach (var item in projectLocationList1) { ReadOnlyCollection <IWebElement> children = item.FindElements(By.XPath(".//*")); if (children[1].Text != string.Empty) { values.Add(children[1].Text); } } ReadOnlyCollection <IWebElement> projectLocationList2 = projectLocationLists[1] .FindElement(By.TagName("ul")) .FindElements(By.TagName("li")); foreach (var item in projectLocationList2) { ReadOnlyCollection <IWebElement> children = item.FindElements(By.XPath(".//*")); if (children[1].Text != string.Empty) { values.Add(children[1].Text); } } if (values.Count() > 1) { for (int a = 0; a < values.Count; a++) { if (a != values.Count() - 1) { Assert.That(values[a], Is.Not.EqualTo(null)); } } for (int i = 0; i < values.Count(); i++) { switch (i) { case 0: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.ShipToName)); break; case 1: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.CountryCode)); break; case 2: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.AddressLine1)); break; case 3: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.Location)); break; case 4: Assert.That(values[i], Is.EqualTo(state)); break; case 5: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.PostalCode)); break; case 6: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.SquareFootage.ToString())); break; case 7: Assert.That(values[i], Is.EqualTo(ShipToAddressModel.NumberOfFloor.ToString())); break; } } } }