public void ToSync_ShouldValidateParameter()
        {
            // Arrange
            IAsyncQueryService <FakeEntity <int>, int> inner = null;

            // Act
            Action action = () => inner.ToSync();

            // Assert
            action.Should().Throw <ArgumentNullException>();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncQueryServiceDecorator{TRoot, TIdentity}"/> class,
 /// decorating the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncQueryService{TRoot, TIdentity}"/> to be decorated.</param>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.</exception>
 public AsyncQueryServiceDecorator(IAsyncQueryService <TRoot, TIdentity> inner)
 {
     Inner = inner ?? throw new ArgumentNullException(nameof(inner));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ComposedAsyncRepository{TRoot,TKey}"/> class.
 /// </summary>
 /// <param name="queryService">The <see cref="IAsyncQueryService{TRoot, TIdentity}"/> to be joined.</param>
 /// <param name="commandService">The <see cref="IAsyncCommandService{TRoot, TIdentity}"/>to be joined.</param>
 /// <exception cref="ArgumentNullException"><paramref name="queryService"/> is <c>null</c>.
 /// -or- <paramref name="commandService"/> is <c>null</c>.</exception>
 public ComposedAsyncRepository(IAsyncQueryService <TRoot, TIdentity> queryService, IAsyncCommandService <TRoot, TIdentity> commandService)
 {
     QueryService   = queryService ?? throw new ArgumentNullException(nameof(queryService));
     CommandService = commandService ?? throw new ArgumentNullException(nameof(commandService));
 }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncQueryServiceExceptionHandler{TRoot, TIdentity, TException}"/> class,
 /// decorating the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncQueryService{TRoot, TIdentity}"/> to be decorated.</param>
 /// <param name="handler">The handler that will be called when an exception is caught.
 /// This delegate must return a flag indicating if the exception was handled.
 /// If it wasn't, it will be re-thrown after processing.</param>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.
 /// -or- <paramref name="handler"/> is <c>null</c>.</exception>
 public AsyncQueryServiceExceptionHandler(IAsyncQueryService <TRoot, TIdentity> inner, Func <TException, bool> handler)
     : base(inner)
 {
     Handler = handler ?? throw new ArgumentNullException(nameof(handler));
 }
 /// <summary>
 /// Joins the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/> and <see cref="IAsyncCommandService{TRoot, TIdentity}"/> into a single <see cref="ComposedAsyncRepository{TRoot, TIdentity}"/>.
 /// </summary>
 /// <typeparam name="TRoot">The type of entities in the data store.</typeparam>
 /// <typeparam name="TIdentity">The type of the unique identity value of the entities in the data store.</typeparam>
 /// <param name="commandService">The <see cref="IAsyncCommandService{TRoot, TIdentity}"/>to be joined.</param>
 /// <param name="queryService">The <see cref="IAsyncQueryService{TRoot, TIdentity}"/> to be joined.</param>
 /// <returns>A new <see cref="ComposedAsyncRepository{TRoot, TIdentity}"/> joining the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/> and <see cref="IAsyncCommandService{TRoot, TIdentity}"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="commandService"/> is <c>null</c>.
 /// -or- <paramref name="queryService"/> is <c>null</c>.</exception>
 public static IAsyncRepository <TRoot, TIdentity> Join <TRoot, TIdentity>(this IAsyncCommandService <TRoot, TIdentity> commandService, IAsyncQueryService <TRoot, TIdentity> queryService)
     where TRoot : IAggregateRoot <TIdentity>
     where TIdentity : IEquatable <TIdentity>, IComparable <TIdentity>
 {
     return(new ComposedAsyncRepository <TRoot, TIdentity>(queryService, commandService));
 }
Example #6
0
 /// <summary>
 /// Wraps the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/> in a <see cref="SyncQueryServiceAdapter{TRoot, TIdentity}"/>.
 /// </summary>
 /// <typeparam name="TRoot">The type of entities in the data store.</typeparam>
 /// <typeparam name="TIdentity">The type of the unique identity value of the entities in the data store.</typeparam>
 /// <param name="inner">The <see cref="IAsyncQueryService{TRoot, TIdentity}"/> to be wrapped.</param>
 /// <returns>A new <see cref="SyncQueryServiceAdapter{TRoot, TIdentity}"/> wrapping the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.</exception>
 public static IQueryService <TRoot, TIdentity> ToSync <TRoot, TIdentity>(this IAsyncQueryService <TRoot, TIdentity> inner)
     where TRoot : IAggregateRoot <TIdentity>
     where TIdentity : IEquatable <TIdentity>, IComparable <TIdentity>
 {
     return(new SyncQueryServiceAdapter <TRoot, TIdentity>(inner));
 }
Example #7
0
 /// <summary>
 /// Wraps the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/> in a <see cref="AsyncQueryServiceExceptionHandler{TRoot, TIdentity, TException}"/>.
 /// </summary>
 /// <typeparam name="TRoot">The type of entities in the data store.</typeparam>
 /// <typeparam name="TIdentity">The type of the unique identity value of the entities in the data store.</typeparam>
 /// <typeparam name="TException">"The type of exception to be handled.</typeparam>
 /// <param name="inner">The <see cref="IAsyncQueryService{TRoot, TIdentity}"/> to be wrapped.</param>
 /// <param name="handler">The handler that will be called when an exception is caught.
 /// This delegate must return a flag indicating if the exception was handled.
 /// If it wasn't, it will be re-thrown after processing.</param>
 /// <returns>A new <see cref="AsyncQueryServiceExceptionHandler{TRoot, TIdentity, TException}"/> wrapping the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.
 /// -or- <paramref name="handler"/> is <c>null</c>.</exception>
 public static IAsyncQueryService <TRoot, TIdentity> Catch <TRoot, TIdentity, TException>(this IAsyncQueryService <TRoot, TIdentity> inner, Func <TException, bool> handler)
     where TRoot : IAggregateRoot <TIdentity>
     where TIdentity : IEquatable <TIdentity>, IComparable <TIdentity>
     where TException : Exception
 {
     return(new AsyncQueryServiceExceptionHandler <TRoot, TIdentity, TException>(inner, handler));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SyncQueryServiceAdapter{TRoot, TIdentity}"/> class,
 /// wrapping the given <see cref="IAsyncQueryService{TRoot, TIdentity}"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncQueryService{TRoot, TIdentity}"/> to be wrapped.</param>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.</exception>
 public SyncQueryServiceAdapter(IAsyncQueryService <TRoot, TIdentity> inner)
     : base(inner)
 {
 }