Esempio n. 1
0
 public void InvalidSubctratingExpression()
 {
     // Act and Assert
     Assert.Throws <IlegalExpressionException>(() => Soql
                                               .From <TestClass>()
                                               .Select((x) => x.MyIntProperty)
                                               .Where((x) => x.MyIntProperty - 1 == 12));
 }
Esempio n. 2
0
        public void NoSelectTest()
        {
            // Arrange
            var expected = SetUpExpectedSelect("MyIntProperty, MyStringProperty, MyBoolProperty__c, MyDateTimeProperty__c, MyDateTimeOffsetProperty, MyEnumProperty");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 3
0
        public void SingleNestedMember()
        {
            // Arrange
            var expected = SetUpExpectedSelect("MyChild__r.MyBoolProperty__c");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyChild.MyBoolProperty)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 4
0
        public void MultipleMemberWithNested()
        {
            // Arrange
            var expected = SetUpExpectedSelect("MyDateTimeProperty__c, MyChild__r.MyBoolProperty__c");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => new { x.MyDateTimeProperty, x.MyChild.MyBoolProperty })
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 5
0
        public void SimpleDateComparision()
        {
            // Arrange
            var expected = SetUpExpectedWhere("MyDateTimeProperty__c = 2020-02-12T12-14-41Z");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => x.MyDateTimeProperty == new DateTime(2020, 02, 12, 12, 14, 41))
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 6
0
        public void SimpleIntegerComparision()
        {
            // Arrange
            var expected = SetUpExpectedWhere("MyIntProperty = 12");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => x.MyIntProperty == 12)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 7
0
        public void MultipleCondition()
        {
            // Arrange
            var expected = SetUpExpectedWhere(@"(MyChild__r.MyIntProperty = 22 OR (MyChild__r.MyChild__r.MyEnumProperty = 'CaseC' AND MyEnumProperty = 'Case A'))");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => x.MyChild.MyIntProperty == 22 || (x.MyChild.MyChild.MyEnumProperty == TestEnum.CaseC && x.MyEnumProperty == TestEnum.CaseA))
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 8
0
        public void AndCondition()
        {
            // Arrange
            var expected = SetUpExpectedWhere(@"(MyChild__r.MyIntProperty = 22 AND MyStringProperty != null)");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => x.MyChild.MyIntProperty == 22 && x.MyStringProperty != null)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 9
0
        public void EnumWithoutAttributeComparision()
        {
            // Arrange
            var expected = SetUpExpectedWhere(@"MyEnumProperty = 'CaseC'");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => x.MyEnumProperty == TestEnum.CaseC)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 10
0
        public void StringEscaping()
        {
            // Arrange
            var expected = SetUpExpectedWhere(@"MyStringProperty = '%hello\' \\\' w\\\\\'\'o%r\\ld \\\'\'\'\\\\\'\\%'");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => x.MyStringProperty == @"%hello' \' w\\''o%r\ld \'''\\'\%")
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 11
0
        public void StringContains()
        {
            // Arrange
            var expected = SetUpExpectedWhere(@"MyStringProperty LIKE '%\%potato\%%'");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => x.MyStringProperty.Contains("%potato%"))
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 12
0
        public void OrderByDescendingTest()
        {
            // Arrange
            var expected = "SELECT MyBoolProperty__c FROM TestClass__c ORDER BY MyDateTimeProperty__c DESCENDING NULLS FIRST";

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyBoolProperty)
                         .OrderBy(x => x.MyDateTimeProperty, OrderByOption.Descending)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 13
0
        public void TakeTest()
        {
            // Arrange
            var expected = "SELECT MyBoolProperty__c FROM TestClass__c LIMIT 2";

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyBoolProperty)
                         .Take(2)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 14
0
        public void IncludeWithSelectTest()
        {
            // Arrange
            var expected = SetUpExpectedSelect("MyBoolProperty__c, MyChild__r.MyChild__r.MyIntProperty, MyChild__r.MyChild__r.MyStringProperty, MyChild__r.MyChild__r.MyBoolProperty__c, MyChild__r.MyChild__r.MyDateTimeProperty__c, MyChild__r.MyChild__r.MyDateTimeOffsetProperty, MyChild__r.MyChild__r.MyEnumProperty");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select(x => x.MyBoolProperty)
                         .Include(x => x.MyChild.MyChild)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 15
0
        public void StringInList()
        {
            // Arrange
            var values   = new string[] { "value_underscopre_a", "value space b" };
            var expected = SetUpExpectedWhere("MyStringProperty IN ('value_underscopre_a', 'value space b')");

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyIntProperty)
                         .Where((x) => values.Contains(x.MyStringProperty))
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 16
0
        public void OrderByThenByTest()
        {
            // Arrange
            var expected = "SELECT MyBoolProperty__c FROM TestClass__c ORDER BY MyDateTimeProperty__c, MyIntProperty, MyStringProperty ASCENDING NULLS FIRST";

            // Act
            var actual = Soql
                         .From <TestClass>()
                         .Select((x) => x.MyBoolProperty)
                         .OrderBy(x => x.MyDateTimeProperty)
                         .ThenBy(x => x.MyIntProperty)
                         .ThenBy(x => x.MyStringProperty)
                         .Build();

            // Assert
            Assert.Equal(expected, actual);
        }
Esempio n. 17
0
 public void InvalidBinaryExpression()
 {
     // Act and Assert
     Assert.Throws <IlegalExpressionException>(() => Soql.From <TestClass>().Select((x) => x.MyBoolProperty == x.MyChild.MyBoolProperty));
 }
Esempio n. 18
0
 public void SkipAboveLimitTest()
 {
     // Assert
     Assert.Throws <ArgumentOutOfRangeException>(() => Soql.From <TestClass>().Select((x) => x.MyBoolProperty).Skip(int.MaxValue));
 }