示例#1
0
 public void AfterScenario()
 {
     if (ScenarioContext.Current.TestError != null)
     {
         ScreenShot.TakeScreenShot();
     }
     SoftAssertions.AssertAll();
     Driver.CloseBrowser();
 }
示例#2
0
        public void SearchCar()
        {
            var softAssert = new SoftAssertions();

            Log.Step(1, "Go to cars sale page");
            var mainPage     = new MainPage();
            var carsSalePage = mainPage.GoToCarsSalePage();

            Log.Step(2, "Searching for cars");
            carsSalePage.FilterCars(Brand, Model);
            var resultPage = new ResultPage();
            var cars       = resultPage.GetAllCars();

            Log.Step(3, "Verifying there are searching results with correct cars");
            foreach (var car in cars)
            {
                Assert.IsTrue(car.Name.Contains(Brand));
            }

            Log.Step(4, "Filter result by price");
            var carsSortedByPrice = resultPage.FilterByPrice();

            Log.Step(5, "Verify that result is filtered  by price");
            var expectedSortingByPrice = cars.OrderByDescending(car => car.Price)
                                         .ThenByDescending(car => car.Year).ToList();

            softAssert.True("Cars are not sorted correctly by Price",
                            expectedSortingByPrice.SequenceEqual(carsSortedByPrice));

            Log.Step(6, "Sort result by year");
            var carsSortedByYear = resultPage.FilterByYear();

            Log.Step(7, "Verify that result is sorted by year");
            var expectedSortingByYear = cars.OrderByDescending(car => car.Year).ToList();

            softAssert.True("Cars are not sorted correctly by Year",
                            expectedSortingByYear.SequenceEqual(carsSortedByYear, new CarDataComparer()));

            Log.Step(8, "Sort result by publish date");
            var carsSortedByDate = resultPage.FilterByDate();

            Log.Step(9, "Verify that result is sorted by publish date");
            var expectedSortingByDate = cars.OrderByDescending(x =>
            {
                DateTime.TryParse(x.Date, out var date);
                return(date);
            })
                                        .ToList();

            softAssert.True("Cars are not sorted correctly by Date",
                            expectedSortingByDate.SequenceEqual(carsSortedByDate, new CarDateComparer()));

            Log.Step(10, "Get assertion errors");
            softAssert.AssertAll();
        }
示例#3
0
        public void VerifyHTTPResponseHeader()
        {
            var response = RestAPIUtil.GetResponse(Config.UrlToJSON);

            var contentTypeOfResponse = response.GetResponseHeader("Content-Type");

            var softAssert = new SoftAssertions();

            softAssert.That(!string.IsNullOrWhiteSpace(contentTypeOfResponse), Resource.ContentTypeIsNull);
            softAssert.That(contentTypeOfResponse.Equals(Resource.ValueOfContentType, StringComparison.InvariantCultureIgnoreCase), string.Format(Resource.IncorrectContentType, Resource.ValueOfContentType));
            softAssert.AssertAll();
        }
示例#4
0
        public void AssertCarsSortingByDate()
        {
            var expectedSortingByDate = _carLists.SortedByDate.OrderByDescending(car =>
            {
                DateTime.TryParse(car.Date, out var date);
                return(date);
            })
                                        .ToList();

            _softAssert.True("Cars are not sorted correctly by Date",
                             expectedSortingByDate.SequenceEqual(_carLists.SortedByDate));
            _softAssert.AssertAll();
        }
示例#5
0
 public void TearDown()
 {
     _softAssertions.AssertAll();
 }