Esempio n. 1
0
    public void Inspector_Throws_FluentQueryHelperException__Catches_And_Rethrows()
    {
        // Arrange
        var collection = new[] { Rnd.Lng };
        var inspectors = new Action <long>[] { _ => throw new EqualTypeException() };

        // Act
        var action = () => FluentQueryHelper.AssertCollection(collection, inspectors);

        // Assert
        Assert.Throws <EqualTypeException>(action);
    }
Esempio n. 2
0
    public void Inspector_Throws_Exception__Catches_And_Throws_As_CollectionException()
    {
        // Arrange
        var collection = new[] { Rnd.Lng };
        var inspectors = new Action <long>[] { _ => throw new InvalidOperationException() };

        // Act
        var action = () => FluentQueryHelper.AssertCollection(collection, inspectors);

        // Assert
        Assert.Throws <CollectionException>(action);
    }
Esempio n. 3
0
    public void Collection_And_Inspectors_Different_Lengths__Throws_CollectionException()
    {
        // Arrange
        var collection = Enumerable.Repeat(Rnd.Str, Rnd.Int).ToArray();
        var inspectors = Enumerable.Repeat((string _) => { }, Rnd.Int).ToArray();

        // Act
        var action = () => FluentQueryHelper.AssertCollection(collection, inspectors);

        // Assert
        Assert.Throws <CollectionException>(action);
    }
Esempio n. 4
0
 /// <summary>
 /// Assert calls to an <see cref="IFluentQuery{TEntity, TId}"/> object
 /// </summary>
 /// <typeparam name="TEntity">Entity Type</typeparam>
 /// <typeparam name="TId">Entity ID Type</typeparam>
 /// <param name="this">Fluent Query object</param>
 /// <param name="inspectors">Call inspectors</param>
 /// <exception cref="CollectionException"></exception>
 public static void AssertCalls <TEntity, TId>(this IFluentQuery <TEntity, TId> @this, params Action <ICall>[] inspectors)
     where TEntity : IWithId <TId>
     where TId : class, IStrongId, new() =>
 FluentQueryHelper.AssertCollection(@this.ReceivedCalls().ToArray(), inspectors);