Example #1
0
        public void TestOrderViews_ShouldRenderOrderDetails()
        {
            OrderViewModelLight orderVMLight = _orderServiceLight.GetNewOrder(user, _quoteId).Model as OrderViewModelLight;

            _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> orderDetailsLists = _driver
                                                                 .FindElement(By.Id("orderDetailsDiv"))
                                                                 .FindElements(By.ClassName("details-list"));

            ReadOnlyCollection <IWebElement> orderDetailsList1 = orderDetailsLists[0]
                                                                 .FindElement(By.TagName("ul"))
                                                                 .FindElements(By.TagName("li"));

            List <string> values = new List <string>();

            foreach (var item in orderDetailsList1)
            {
                ReadOnlyCollection <IWebElement> children = item.FindElements(By.XPath(".//*"));
                if (children.Count() < 3)
                {
                    if (children[1].Text != string.Empty)
                    {
                        values.Add(children[1].Text);
                    }
                }
            }

            ReadOnlyCollection <IWebElement> orderDetailsList2 = orderDetailsLists[1]
                                                                 .FindElement(By.TagName("ul"))
                                                                 .FindElements(By.TagName("li"));

            foreach (var item in orderDetailsList2)
            {
                ReadOnlyCollection <IWebElement> children = item.FindElements(By.XPath(".//*"));
                if (children.Count() < 3)
                {
                    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(orderVMLight.SubmittedByUserName));
                        break;

                    case 1:
                        if (orderVMLight.OrderId != 0)
                        {
                            Assert.That(values[i], Is.EqualTo(orderVMLight.OrderReleaseDate.ToString("MM/dd/yyyy")));
                        }
                        break;

                    case 2:
                        if (orderVMLight.OrderId != 0)
                        {
                            Assert.That(values[i], Is.EqualTo(orderVMLight.PONumber));
                        }
                        break;

                    case 3:
                        Assert.That(values[i], Is.EqualTo(orderVMLight.TotalNetPrice.ToString()));
                        break;

                    case 4:
                        Assert.That(values[i], Is.EqualTo(orderVMLight.TotalDiscountPercent.ToString()));
                        break;

                    case 5:
                        if (orderVMLight.OrderId != 0)
                        {
                            Assert.That(values[i], Is.EqualTo(orderVMLight.Comments));
                        }
                        break;
                    }
                }
            }
        }
Example #2
0
 public void TestOrderAPI_GetNewOrder_ReturnNewOrderViewModelLight()
 {
     Response = orderServiceLight.GetNewOrder(user, quoteModel.QuoteId.Value);
     Assert.That(Response.Model, Is.Not.EqualTo(null));
 }
Example #3
0
 public ServiceResponse GetNewOrder(long quoteId)
 {
     return(_orderServiceLight.GetNewOrder(this.CurrentUser, quoteId));
 }