Пример #1
0
        public void SortByField_WhenOptionDescending_ShouldSortNameDescending()
        {
            // Arrange
            _sut = new SortService();

            var unsorted   = Unsorted();
            var sortOption = "Descending";
            var current    = unsorted.Max(p => p.Name);

            // Act
            var sorted = _sut.SortByField(unsorted, sortOption);

            // Assert
            foreach (var product in sorted)
            {
                Assert.True(string.Compare(current, product.Name) >= 0);
                current = product.Name;
            }
        }
Пример #2
0
        public void SortByField_WhenOptionHigh_ShouldSortPriceDescending()
        {
            // Arrange
            _sut = new SortService();

            var unsorted   = Unsorted();
            var sortOption = "High";
            var current    = unsorted.Max(p => p.Price);

            // Act
            var sorted = _sut.SortByField(unsorted, sortOption);

            // Assert
            foreach (var product in sorted)
            {
                Assert.True(current >= product.Price);
                current = product.Price;
            }
        }