Example #1
0
        public void GetEstates_Pagination_OneAdToPage_SecondPage()
        {
            // Arrange
            var          estateRepo     = new EstatesRepository(_context);
            EstateParams estateParams   = new EstateParams();
            var          resultExpected = estateRepo.GetEstates(estateParams)
                                          .Result
                                          .ToList();

            estateParams.PageSize   = 1;
            estateParams.PageNumber = 2;
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            Assert.AreEqual(resultExpected[1], result.Result[0]);
        }
Example #2
0
        public void GetEstates_Filtering_ByStreet()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams   = new EstateParams();
            var          resultExpected = estateRepo.GetEstates(estateParams)
                                          .Result
                                          .Where(e => e.Street == "Shevchenka")
                                          .ToList();

            estateParams.Street = "Shevchenka";
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            CollectionAssert.AreEqual(resultExpected, result.Result);
        }
Example #3
0
        public void GetEstates_Filtering_ByCountry()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams   = new EstateParams();
            var          resultExpected = estateRepo.GetEstates(estateParams)
                                          .Result
                                          .Where(e => e.Country == "Ukraine")
                                          .ToList();

            estateParams.Country = "Ukraine";
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            CollectionAssert.AreEqual(resultExpected, result.Result);
        }
Example #4
0
        public void GetEstates_Filtering_OrderBySquareDown()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams   = new EstateParams();
            var          resultExpected = estateRepo.GetEstates(estateParams)
                                          .Result
                                          .OrderByDescending(e => e.Square)
                                          .ToList();

            estateParams.OrderBy = "squareDown";
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            CollectionAssert.AreEqual(resultExpected, result.Result);
        }
Example #5
0
        public void GetEstates_Filtering_OrderByRoomsUp()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams   = new EstateParams();
            var          resultExpected = estateRepo.GetEstates(estateParams)
                                          .Result
                                          .OrderBy(e => e.Rooms)
                                          .ToList();

            estateParams.OrderBy = "roomsUp";
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            CollectionAssert.AreEqual(resultExpected, result.Result);
        }
Example #6
0
        public void GetEstates_Filtering_TypeSelling()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams = new EstateParams()
            {
                Type = "Selling"
            };
            var resultExpected = estateRepo.GetEstates(estateParams)
                                 .Result
                                 .Where(e => e.AdType == "Selling")
                                 .ToList();
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            CollectionAssert.AreEqual(resultExpected, result.Result);
        }
Example #7
0
        public void GetEstates_Filtering_FloorsMinMax()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams   = new EstateParams();
            var          resultExpected = estateRepo.GetEstates(estateParams)
                                          .Result
                                          .Where(e => e.Floors >= 1 && e.Floors <= 2)
                                          .ToList();

            estateParams.MinFloors = 1;
            estateParams.MaxFloors = 2;
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            CollectionAssert.AreEqual(resultExpected, result.Result);
        }
Example #8
0
        public void GetEstates_Filtering_SquareMinMax()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams   = new EstateParams();
            var          resultExpected = estateRepo.GetEstates(estateParams)
                                          .Result
                                          .Where(e => e.Square >= 50 && e.Square <= 100)
                                          .ToList();

            estateParams.MinSquare = 50;
            estateParams.MaxSquare = 100;
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            CollectionAssert.AreEqual(resultExpected, result.Result);
        }
Example #9
0
        public void GetEstates_Pagination_OneAdToPage()
        {
            // Arrange
            var estateRepo = new EstatesRepository(_context);

            EstateParams estateParams = new EstateParams()
            {
                PageSize = 1
            };
            // Act
            var result = estateRepo.GetEstates(estateParams);

            // Assert
            Assert.IsTrue(result.Result.Count == 1);
        }