Example #1
0
    public void Parameters_Not_Equal__Throws_EqualJsonException()
    {
        // Arrange
        var fluent = Create();
        var clause = Rnd.Str;

        fluent.Where(clause, new { value = Rnd.Lng });

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere(c, clause, new { value = Rnd.Lng });

        // Assert
        Assert.Throws <EqualJsonException>(() => fluent.AssertCalls(action));
    }
Example #2
0
    public void Clause_Not_Equal_Throws_EqualTypeException()
    {
        // Arrange
        var fluent     = Create();
        var parameters = new { value = Rnd.Guid };

        fluent.Where(Rnd.Str, parameters);

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere(c, Rnd.Str, parameters);

        // Assert
        Assert.Throws <EqualTypeException>(() => fluent.AssertCalls(action));
    }
Example #3
0
    public void No_Generic_Argument__Throws_GenericArgumentException()
    {
        // Arrange
        var fluent  = Create();
        var compare = Compare.Like;
        var value   = Rnd.Str;

        fluent.Where(nameof(TestEntity.Foo), compare, value);

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere <TestEntity, string>(c, x => x.Foo, compare, value);

        // Assert
        Assert.Throws <GenericArgumentException>(() => fluent.AssertCalls(action));
    }
Example #4
0
    public void Incorrect_Method__Throws_MethodNameException()
    {
        // Arrange
        var fluent = Create();

        fluent.Maximum(Rnd.ULng);

        // Act
        var a0 = (ICall c) => FluentQueryHelper.AssertWhere <TestEntity, string>(c, x => x.Foo, Compare.Equal, Rnd.Str);
        var a1 = (ICall c) => FluentQueryHelper.AssertWhere(c, Rnd.Str, Rnd.Str);

        // Assert
        Assert.Throws <MethodNameException>(() => fluent.AssertCalls(a0));
        Assert.Throws <MethodNameException>(() => fluent.AssertCalls(a1));
    }
Example #5
0
    public void With_Nullable_Value__Asserts_Where()
    {
        // Arrange
        var  fluent  = Create();
        var  compare = Compare.NotEqual;
        long?value   = Rnd.Lng;

        fluent.Where(x => x.Nll, compare, value);

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere <TestEntity, long?>(c, x => x.Nll, compare, value);

        // Assert
        fluent.AssertCalls(action);
    }
Example #6
0
    public void With_Clause__Asserts_Where()
    {
        // Arrange
        var fluent     = Create();
        var clause     = Rnd.Str;
        var parameters = new { value = Rnd.Lng };

        fluent.Where(clause, parameters);

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere(c, clause, parameters);

        // Assert
        fluent.AssertCalls(action);
    }
Example #7
0
    public void With_Property_Expression__Asserts_Where()
    {
        // Arrange
        var fluent  = Create();
        var compare = Compare.Like;
        var value   = Rnd.Str;

        fluent.Where(x => x.Foo, compare, value);

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere <TestEntity, string>(c, x => x.Foo, compare, value);

        // Assert
        fluent.AssertCalls(action);
    }
Example #8
0
    public void Compare_Not_Equal__Throws_EqualTypeException()
    {
        // Arrange
        var fluent = Create();
        var c0     = Compare.Is;
        var c1     = Compare.IsNot;

        fluent.Where(x => x.Foo, c0, Rnd.Str);

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere <TestEntity, string>(c, x => x.Foo, c1, Rnd.Str);

        // Assert
        Assert.Throws <EqualTypeException>(() => fluent.AssertCalls(action));
    }
Example #9
0
    public void Value_Not_Equal__Throws_EqualTypeException()
    {
        // Arrange
        var fluent  = Create();
        var v0      = Rnd.Lng;
        var v1      = Rnd.Lng;
        var compare = Compare.LessThanOrEqual;

        fluent.Where(x => x.Bar, compare, v0);

        // Act
        var action = (ICall c) => FluentQueryHelper.AssertWhere <TestEntity, long>(c, x => x.Bar, compare, v1);

        // Assert
        Assert.Throws <EqualTypeException>(() => fluent.AssertCalls(action));
    }