コード例 #1
0
 public void enum_handling()
 {
     Get(d => d.Order == SomeEnum.First).Should().Be("(Order = @0)");
     FirstParameter.Should().Be(SomeEnum.First);
     FirstParameter.Should().NotBe((int)SomeEnum.First);
     FirstParameter.Should().BeOfType <SomeEnum>();
 }
コード例 #2
0
        public void min_of_expression()
        {
            var sql = Get(d => d.Min(d.SomeId * 5));

            sql.Should().Be("min((SomeId * @0))");
            FirstParameter.Should().Be(5);
        }
コード例 #3
0
        public void concat_columns()
        {
            var sql = Get(d => d.Concat(d.SomeId, "g", d.Title));

            sql.Should().Be("concat(SomeId,@0,Title)");
            FirstParameter.Should().Be("g");
        }
コード例 #4
0
        public void id_equals_field_or_title_is_null()
        {
            var d = Guid.Empty;

            Get(p => p.Id == d || p.Title == null).Should().Be("((Id = @0) or (Title is null))");
            FirstParameter.Should().Be(d);
        }
コード例 #5
0
        public void enum_from_method_handling()
        {
            Expression <Func <ClassA, bool> > func = x => x.Enum == Get();

            _sut.GetSql(func).Should().Be("(Enum = @0)");
            FirstParameter.Should().Be(SomeEnum.Last);
        }
コード例 #6
0
        public void string_length()
        {
            A.CallTo(() => _provider.Length("Title")).Returns("len(Title)");
            Get(d => d.Title.Length == 2).Should().Be("(len(Title) = @0)");

            FirstParameter.Should().Be(2);
        }
コード例 #7
0
        public void round_columns()
        {
            var sql = Get(d => d.Round(d.SomeId, 3));

            sql.Should().Be("round(SomeId,@0)");
            FirstParameter.Should().Be(3);
        }
コード例 #8
0
        public void projection_with_column_calculation()
        {
            _l = d => new { d.Id, Name = d.SomeId + 1 };
            var sql = _sut.GetColumnsSql(_l);

            sql.Should().Be("Id as Id,(SomeId + @0) as Name");
            FirstParameter.Should().Be(1);
        }
コード例 #9
0
        public void enum_variable_handling()
        {
            var e = SomeEnum.First;

            Expression <Func <ClassA, bool> > func = x => x.Enum == e;

            _sut.GetSql(func).Should().Be("(Enum = @0)");
            FirstParameter.Should().Be(SomeEnum.First);
        }
コード例 #10
0
        public void sum_of_column()
        {
            var sql = Get(d => d.Sum(d.IsActive));

            sql.Should().Be("sum(IsActive)");

            Get(d => d.Sum(d.SomeId + 6)).Should().Be("sum((SomeId + @0))");
            FirstParameter.Should().Be(6);
        }
コード例 #11
0
        public void simple_inequality_criteria()
        {
            Get(d => d.SomeId != 24).Should().Be("(SomeId <> @0)");
            FirstParameter.Should().Be(24);
            _sut.Parameters.Clear();
            var i = 24;

            Get(d => d.SomeId != i).Should().Be("(SomeId <> @0)");
            FirstParameter.Should().Be(24);
        }
コード例 #12
0
        public void handle_nullable_boolean_property_true()
        {
            Get(d => d.IsBla).Should().Be("IsBla=@0");
            FirstParameter.Should().Be(true);

            _sut.Parameters.Clear();
            bool?b = true;

            Get(d => d.IsBla == b.Value).Should().Be("IsBla=@0");
            FirstParameter.Should().Be(true);

            _sut.Parameters.Clear();
            Get(d => d.IsBla == b).Should().Be("IsBla=@0");
            FirstParameter.Should().Be(true);
        }
コード例 #13
0
 public void id_greater_than_12_and_less_than_24()
 {
     Get(p => p.SomeId > 12 && p.SomeId < 24).Should().Be("((SomeId > @0) and (SomeId < @1))");
     FirstParameter.Should().Be(12);
     Parameter(1).Should().Be(24);
 }
コード例 #14
0
 public void enum_that_requires_casting_handling()
 {
     Get(d => d.Order == (SomeEnum?)1).Should().Be("(Order = @0)");
     FirstParameter.Should().Be(SomeEnum.First);
     FirstParameter.Should().BeOfType <SomeEnum>();
 }
コード例 #15
0
 public void id_and_isActive_is_explicitely_true()
 {
     Get(d => d.SomeId == 23 && d.IsActive == true).Should().Be("((SomeId = @0) and IsActive=@1)");
     FirstParameter.Should().Be(23);
     Parameter(1).Should().Be(true);
 }
コード例 #16
0
 public void id_and_isActive_not_true()
 {
     Get(d => d.SomeId == 23 && !d.IsActive).Should().Be("((SomeId = @0) and IsActive=@1)");
     FirstParameter.Should().Be(23);
     Parameter(1).Should().Be(false);
 }
コード例 #17
0
 public void handle_nullable_boolean_property_false()
 {
     Get(d => !d.IsBla).Should().Be("IsBla=@0");
     FirstParameter.Should().Be(false);
 }
コード例 #18
0
 public void string_contains()
 {
     Get(d => d.Title.Contains("''t")).Should().Be("Title like @0");
     FirstParameter.Should().Be("%''t%");
 }
コード例 #19
0
 public void string_ends_with()
 {
     Get(d => d.Title.EndsWith("t")).Should().Be("Title like @0");
     FirstParameter.Should().Be("%t");
 }
コード例 #20
0
 public void string_starts_with()
 {
     Get(d => d.Title.StartsWith("t")).Should().Be("Title like @0");
     FirstParameter.Should().Be("t%");
 }
コード例 #21
0
 public void nullable_property_equality()
 {
     Get(p => p.Order == SomeEnum.Last).Should().Be("(Order = @0)");
     FirstParameter.Should().Be(SomeEnum.Last);
 }