示例#1
0
        public void Parse_WithShortPropertyName()
        {
            var sortExpression = "Product";

            var result = _parser.Parse(sortExpression);

            var expected = new[] { SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_productPropertyDefinition) };

            Assert.That(result.SortedProperties, Is.EqualTo(expected));
        }
示例#2
0
        public void Parse_WithRealRelationEndPoint()
        {
            var sortExpression = "Order";

            var result = _parser.Parse(sortExpression);

            var expected = new[] { SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_orderPropertyDefinition) };

            Assert.That(result.SortedProperties, Is.EqualTo(expected));
        }
示例#3
0
        public void Parse_WithFullIdentifier()
        {
            var sortExpression = "Remotion.Data.DomainObjects.UnitTests.TestDomain.OrderItem.Product";

            var result = _parser.Parse(sortExpression);

            var expected = new[] { SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_productPropertyDefinition) };

            Assert.That(result.SortedProperties, Is.EqualTo(expected));
        }
示例#4
0
        public void Parse_WithOrderSpecification_MultipleSpaces()
        {
            var sortExpression = "Product  desc";

            var result = _parser.Parse(sortExpression);

            var expected = new[] { SortExpressionDefinitionObjectMother.CreateSortedPropertyDescending(_productPropertyDefinition) };

            Assert.That(result.SortedProperties, Is.EqualTo(expected));
        }
示例#5
0
        public void Parse_Many_TrailingComma()
        {
            var sortExpression = "Product asc,Position,Order desc,";

            var result = _parser.Parse(sortExpression);

            var expected = new[]
            {
                SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_productPropertyDefinition),
                SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_positionPropertyDefinition),
                SortExpressionDefinitionObjectMother.CreateSortedPropertyDescending(_orderPropertyDefinition)
            };

            Assert.That(result.SortedProperties, Is.EqualTo(expected));
        }
示例#6
0
        public void Parse_WithDerivedProperty()
        {
            var partnerClassDefinition = MappingConfiguration.Current.GetTypeDefinition(typeof(Partner));
            var parser = new SortExpressionParser(partnerClassDefinition);

            var sortExpression = "Remotion.Data.DomainObjects.UnitTests.TestDomain.Distributor.NumberOfShops";

            var result = parser.Parse(sortExpression);

            var distributorClassDefinition      = MappingConfiguration.Current.GetTypeDefinition(typeof(Distributor));
            var numberOfShopsPropertyDefinition = distributorClassDefinition.GetMandatoryPropertyDefinition(sortExpression);
            var expected = new[] { SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(numberOfShopsPropertyDefinition) };

            Assert.That(result.SortedProperties, Is.EqualTo(expected));
        }
示例#7
0
        public void Parse_RoundTrip()
        {
            var sortExpression = "Product asc, Position, Order desc";

            var result1 = _parser.Parse(sortExpression);
            var result2 = _parser.Parse(result1.ToString());

            var expected = new[]
            {
                SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_productPropertyDefinition),
                SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_positionPropertyDefinition),
                SortExpressionDefinitionObjectMother.CreateSortedPropertyDescending(_orderPropertyDefinition)
            };

            Assert.That(result2.SortedProperties, Is.EqualTo(expected));
        }
示例#8
0
        public new void ToString()
        {
            var sortExpressionDefinition =
                new SortExpressionDefinition(
                    new[]
            {
                SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(_productPropertyDefinition),
                SortExpressionDefinitionObjectMother.CreateSortedPropertyDescending(_positionPropertyDefinition)
            });

            var result = sortExpressionDefinition.ToString();

            var expected =
                "Remotion.Data.DomainObjects.UnitTests.TestDomain.OrderItem.Product ASC, "
                + "Remotion.Data.DomainObjects.UnitTests.TestDomain.OrderItem.Position DESC";

            Assert.That(result, Is.EqualTo(expected));
        }