public void VerifyTotalNumberOfOrdersVersusStopsCalculatesCorrectlyForDisplayedRoutes() { DisplayedRoutes.Count().Should().BeGreaterOrEqualTo(1, "No Routes were found. Please verify if routes should have been displayed."); var limit = 0; int currentRouteId; string currentRouteNumber; int currentTotalNumberOrders; int currentTotalNumberStops; foreach (var currentRoute in DisplayedRoutes) { //For now hardcoding to only check 20 routes if (limit < 20) { currentRouteId = Convert.ToInt32(currentRoute.GetAttribute("data-route-id")); currentRouteNumber = currentRoute.GetAttribute("data-number").Trim(); var expectedTotalOrdersAndTotalStops = DbHelper.CalculateExpectedTotalOrdersVersusTotalStopsForGivenRouteId(currentRouteId.ToString()); currentTotalNumberOrders = expectedTotalOrdersAndTotalStops.Item1; currentTotalNumberStops = expectedTotalOrdersAndTotalStops.Item2; //Example: (4/8 orders) where 4 orders exist and that route has 8 stops var expectedTotalOrdersVsTotalStops = $"({currentTotalNumberOrders}/{currentTotalNumberStops} orders)"; //Retrieve the total number of orders out of the total number of routes from the UI var actualTotalOrdersVsTotalStops = TotalNumberOfOrdersVsTotalStopsForRoute(currentRouteId).GetText(); actualTotalOrdersVsTotalStops.Should().Be(expectedTotalOrdersVsTotalStops, $"Route #{currentRouteNumber} had {currentTotalNumberOrders} in the the API"); } limit++; } }
public void VerifyCapacityTotalsCalculatedCorrectlyForDisplayedRoutes() { var limit = 0; decimal actualTotalCubes; decimal actualTotalCases; decimal actualTotalLbs; int currentRouteId; string currentRouteNumber; DisplayedRoutes.Count().Should().BeGreaterOrEqualTo(1, "No Routes were found. Please verify why routes were not displayed."); //For every route shown foreach (var currentRoute in DisplayedRoutes) { //For now hardcoding to only check 20 routes if (limit < 20) { currentRouteId = Convert.ToInt32(currentRoute.GetAttribute("data-route-id")); currentRouteNumber = currentRoute.GetAttribute("data-number").Trim(); actualTotalCubes = Convert.ToDecimal(CubesColumn(currentRouteId).GetText()); //Retrieve the Total Cubes for the route actualTotalCases = Convert.ToDecimal(CasesColumn(currentRouteId).GetText()); //Retrieve the Total Cases for the route actualTotalLbs = Convert.ToDecimal(LBsColumn(currentRouteId).GetText()); //Retrieve the Total LBs for the route //Use the API to calculate the expected capacity totals for the routeId var expectedCapacityTotals = DbHelper.CalculateExpectedCapacityTotalsForRouteId(currentRouteId.ToString()); //Verify actual capacity total match expected actualTotalCubes.Should().BeApproximately((expectedCapacityTotals.Item1), 1, $"Route {currentRouteNumber} Total Cubes should have been within 1 unit of expected"); actualTotalCases.Should().BeApproximately((expectedCapacityTotals.Item2), 1, $"Route {currentRouteNumber} Total Cases should have been within 1 unit of expected"); actualTotalLbs.Should().BeApproximately((expectedCapacityTotals.Item3), 1, $"Route {currentRouteNumber} Total LBs should have been within 1 unit of expected"); } limit++; } }
public void GetRandomRouteFromRoutesShown() { Random rnd = new Random(); var randomIndex = rnd.Next(0, DisplayedRoutes.Count() - 1); var routeId = DisplayedRoutes.ElementAt(randomIndex).GetAttribute("data-route-id"); var routeNumber = DisplayedRoutes.ElementAt(randomIndex).GetAttribute("data-number").Trim(); ScenarioContext.Current["SelectedRouteId"] = routeId; ScenarioContext.Current["SelectedRouteNumber"] = routeNumber; }
public void VerifyAllRouteShownHaveGivenOrderFilter(string orderFilterValue) { var limit = 0; DisplayedRoutes.Count().Should().BeGreaterOrEqualTo(1, "No Routes were returned for the specified criteria. Please verify if routes should have been returned."); //For every route shown foreach (var route in DisplayedRoutes) { //For now hardcoding to only check 20 routes if (limit < 20) { //Use the API to find out what order classification the current route should be var routeExpectedOrderFilterValue = DbHelper.GenerateOrderClassificationForRouteId(route.GetAttribute("data-route-id")); orderFilterValue.Should().Be(routeExpectedOrderFilterValue, $"The route should have been clasified as {routeExpectedOrderFilterValue}, but was classified as {orderFilterValue} in the UI"); } limit++; } }