public CreatePaymentConsumer(IAsyncUnitOfWork unitOfWork, IRepository <Payment, Guid> paymentRepository, IServiceClient serviceClient, Client.IServiceClient billsServiceClient)
 {
     _unitOfWork         = unitOfWork;
     _paymentRepository  = paymentRepository;
     _serviceClient      = serviceClient;
     _billsServiceClient = billsServiceClient;
 }
예제 #2
0
 public DatabaseDataStore(IAsyncUnitOfWork unitOfWork,
                          IRepository repository, IAsyncDataLoader dataLoader,
                          IEntityFactory entityFactory, IDateTimeAdapter dateTimeAdapter)
 {
     this.DataLoader      = dataLoader;
     this.UnitOfWork      = unitOfWork;
     this.Repository      = repository;
     this.EntityFactory   = entityFactory;
     this.DateTimeAdapter = dateTimeAdapter;
 }
예제 #3
0
        public async Task Basic_Transaction_Management_Async()
        {
            ParentModel initial = null;
            ParentModel intrans = null;
            ParentModel outside = null;
            int         id;

            TestHarnessRepository repo2 = new TestHarnessRepository(_provider);
            TestHarnessRepository repo3 = new TestHarnessRepository(_provider);

            IAsyncUnitOfWork uow = await _repo.CreateAsyncUnitOfWork(new[] { _repo, repo2, repo3 });

            using (uow)
            {
                try
                {
                    initial = await _repo.GetOnlyParentByNameAsync("crm");

                    id = initial.Id;

                    initial = await _repo.GetParentByIdAsync(id);

                    await repo2.InsertChildAsync(new ClientRedirectUri
                    {
                        ClientId = id,
                        Uri      = "asdfasdf"
                    });

                    await repo3.InsertChildAsync(new ClientRedirectUri
                    {
                        ClientId = id,
                        Uri      = "fdsafdsa"
                    });

                    intrans = await _repo.GetParentByIdAsync(id);

                    await _repo.DbOperationAsync("crm");
                }
                finally
                {
                    uow.RollbackTransaction();
                }
            }

            outside = await _repo.GetParentByIdAsync(id);

            initial.Should().NotBeNull();
            intrans.Should().NotBeNull();
            outside.Should().NotBeNull();
            initial.Children.Should().NotBeNullOrEmpty();
            intrans.Children.Should().NotBeNullOrEmpty();
            outside.Children.Should().NotBeNullOrEmpty();
            initial.Children.Count().Should().Be(intrans.Children.Count() - 2);
            initial.Children.Count().Should().Be(outside.Children.Count());
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncUnitOfWorkTap"/> class.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> to be decorated.</param>
 /// <param name="tap">The tap <see cref="IAsyncUnitOfWork"/>, where commands will be mirrored.</param>
 /// <param name="logger">The logger where tap exceptions should be written.</param>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.
 /// -or- <paramref name="tap"/> is <c>null</c>.</exception>
 public AsyncUnitOfWorkTap(IAsyncUnitOfWork inner, IAsyncUnitOfWork tap, ILogger logger)
     : base(inner)
 {
     Logger = logger;
     Tap    = (tap ?? throw new ArgumentNullException(nameof(tap)))
              .Catch((Exception ex) =>
     {
         Logger?.LogWarning(0, ex, "An exception ocurred in the 'tap' unit of work.");
         return(true);
     });
 }
        public void ToSync_ShouldValidateParameter()
        {
            // Arrange
            IAsyncUnitOfWork inner = null;

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

            // Assert
            action.Should().Throw <ArgumentNullException>();
        }
예제 #6
0
 public SportEventController(
     IRepository <SportEvent> repository,
     IAsyncReadonlyRepository <SportEvent> readonlyRepository,
     IAsyncUnitOfWork unitOfWork,
     AbstractValidator <SportEvent> validator
     )
 {
     this.repository         = repository;
     this.readonlyRepository = readonlyRepository;
     this.unitOfWork         = unitOfWork;
     this.validator          = validator;
 }
 public GoogleCalendarServiceAdapter(IAsyncUnitOfWork unitOfWork,
                                     IAsyncDataLoader dataLoader, IRepository repository,
                                     IGoogleCalendarServiceFactory serviceFactory, IDateTimeAdapter dateTimeAdapter,
                                     IGoogleObjectFactory objectFactory, ILivitConfiguration configuration)
     : base(unitOfWork, dataLoader)
 {
     this.Repository         = repository;
     this.ServiceFactory     = serviceFactory;
     this.ObjectFactory      = objectFactory;
     this.DateTimeAdapter    = dateTimeAdapter;
     this.LivitConfiguration = configuration;
 }
예제 #8
0
 public GoogleAuthenticationService(IAsyncUnitOfWork unitOfWork,
                                    IAsyncDataLoader dataLoader, ILivitConfiguration configuration,
                                    HttpClient client, IDataStore dataStore, ITokenService tokenService,
                                    IGoogleAuthorizationCodeFlowFactory authorizationFlowFactory,
                                    IServiceObjectFactory objectFactory)
     : base(unitOfWork, dataLoader, configuration)
 {
     this.Client                   = client;
     this.DataStore                = dataStore;
     this.TokenService             = tokenService;
     this.ObjectFactory            = objectFactory;
     this.AuthorizationFlowFactory = authorizationFlowFactory;
 }
        public async void GetAsyncUnitOfWork_Should_Return_From_List()
        {
            IEnumerable <IBaseRepository> repos = new List <IBaseRepository>
            {
                new FakeRepository(_provider.Object),
                new FakeRepository(_provider.Object),
                new FakeRepository(_provider.Object),
                new FakeRepository(_provider.Object)
            };

            IAsyncUnitOfWork uow = await repos.CreateAsyncUnitOfWork();

            uow.Should().Be(_mockAuow.Object);
        }
예제 #10
0
 public static async Task WrapTestDbOperationsAsync(this IBaseRepositoryTest tests, List <IBaseRepository> repos, Func <Task> work)
 {
     using (IAsyncUnitOfWork uow = await repos.CreateAsyncUnitOfWork())
     {
         try
         {
             await uow.BeginTransactionAsync();
             await work();
         }
         finally
         {
             uow.RollbackTransaction();
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncUnitOfWorkDecorator"/> class,
 /// decorating the given <see cref="IAsyncUnitOfWork"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> to be decorated.</param>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.</exception>
 public AsyncUnitOfWorkDecorator(IAsyncUnitOfWork inner)
 {
     Inner = inner ?? throw new ArgumentNullException(nameof(inner));
 }
예제 #12
0
 /// <summary>
 /// Wraps the given <see cref="IAsyncUnitOfWork"/> in a <see cref="SyncUnitOfWorkAdapter"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> to be wrapped.</param>
 /// <returns>A new <see cref="SyncUnitOfWorkAdapter"/> wrapping the given <see cref="IAsyncUnitOfWork"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.</exception>
 public static IUnitOfWork ToSync(this IAsyncUnitOfWork inner)
 {
     return(new SyncUnitOfWorkAdapter(inner));
 }
예제 #13
0
 protected AuthenticationServiceBase(IAsyncUnitOfWork unitOfWork, IAsyncDataLoader dataLoader,
                                     ILivitConfiguration configuration)
     : base(unitOfWork, dataLoader)
 {
     this.Configuration = configuration;
 }
예제 #14
0
 /// <summary>
 /// Wraps the given <see cref="IAsyncUnitOfWork"/> in a sequential <see cref="AsyncUnitOfWorkTap"/>,
 /// mirroring all commands to the other given <see cref="IAsyncUnitOfWork"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> to be wrapped.</param>
 /// <param name="tap">The tap <see cref="IAsyncUnitOfWork"/>, where commands will be mirrored.</param>
 /// <param name="logger">The <see cref="ILogger"/> to which any tap exceptions should be written.</param>
 /// <returns>A new <see cref="AsyncUnitOfWorkTap"/> wrapping the two given <see cref="IAsyncUnitOfWork"/> instances.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.
 /// -or- <paramref name="tap"/> is <c>null</c>.</exception>
 public static IAsyncUnitOfWork WithSequentialTap(this IAsyncUnitOfWork inner, IAsyncUnitOfWork tap, ILogger logger)
 {
     return(new AsyncUnitOfWorkTap(inner, tap, logger));
 }
예제 #15
0
 /// <summary>
 /// Wraps the given <see cref="IAsyncUnitOfWork"/> in a parallel <see cref="AsyncUnitOfWorkTap"/>,
 /// mirroring all commands to the other given <see cref="IAsyncUnitOfWork"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> to be wrapped.</param>
 /// <param name="tap">The tap <see cref="IAsyncUnitOfWork"/>, where commands will be mirrored.</param>
 /// <param name="logger">The <see cref="ILogger"/> to which any tap exceptions should be written.</param>
 /// <returns>A new <see cref="AsyncUnitOfWorkTap"/> wrapping the two given <see cref="IAsyncUnitOfWork"/> instances.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.
 /// -or- <paramref name="tap"/> is <c>null</c>.</exception>
 public static IAsyncUnitOfWork WithParallelTap(this IAsyncUnitOfWork inner, IAsyncUnitOfWork tap, ILogger logger)
 {
     return(new AsyncUnitOfWorkParallelTap(inner, tap, logger));
 }
 public RegistratorAddedConsumer(IRepository <Registrator, Guid> repository, IAggregateFactory <Registrator, FactoryInput, Guid> factory, IAsyncUnitOfWork asyncUnitOfWork)
 {
     _repository      = repository;
     _factory         = factory;
     _asyncUnitOfWork = asyncUnitOfWork;
 }
예제 #17
0
 public MeterReadProcessFinishedConsumer(IAsyncUnitOfWork asyncUnitOfWork, IRepository <MeterRead, Guid> meterReadRepository)
 {
     _asyncUnitOfWork     = asyncUnitOfWork;
     _meterReadRepository = meterReadRepository;
 }
 public SendPaymentNotificationConsumer(PaymentNotificationDomainService domainService, IAsyncUnitOfWork asyncUnitOfWork)
 {
     _domainService   = domainService;
     _asyncUnitOfWork = asyncUnitOfWork;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncUnitOfWorkTap"/> class.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> to be decorated.</param>
 /// <param name="tap">The tap <see cref="IAsyncUnitOfWork"/>, where commands will be mirrored.</param>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.
 /// -or- <paramref name="tap"/> is <c>null</c>.</exception>
 public AsyncUnitOfWorkTap(IAsyncUnitOfWork inner, IAsyncUnitOfWork tap)
     : this(inner, tap, null)
 {
 }
 public RegisteredAcceptedPaymentConsumer(IRepository <Address, Guid> addressRepository, IAsyncUnitOfWork asyncUnitOfWork)
 {
     _addressRepository = addressRepository;
     _asyncUnitOfWork   = asyncUnitOfWork;
 }
        public async Task Invoke(HttpContext context, IAsyncUnitOfWork unitOfWork)
        {
            await _next.Invoke(context);

            await unitOfWork.CommitAsync();
        }
예제 #22
0
 public CreateUsageCalculationConsumer(UsageDomainService usageDomainService, IAsyncUnitOfWork asyncUnitOfWork)
 {
     _usageDomainService = usageDomainService;
     _asyncUnitOfWork    = asyncUnitOfWork;
 }
예제 #23
0
 protected LeaveManagementService(IAsyncUnitOfWork unitOfWork, IAsyncDataLoader dataLoader)
     : base(unitOfWork, dataLoader)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SyncUnitOfWorkAdapter"/> class,
 /// wrapping the given <see cref="IAsyncUnitOfWork"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> to be wrapped.</param>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.</exception>
 public SyncUnitOfWorkAdapter(IAsyncUnitOfWork inner)
     : base(inner)
 {
 }
예제 #25
0
 protected LivitServiceBase(IAsyncUnitOfWork unitOfWork, IAsyncDataLoader dataLoader)
 {
     this.UnitOfWork = unitOfWork;
     this.DataLoader = dataLoader;
 }
예제 #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AsyncUnitOfWorkExceptionHandler{TException}"/> class,
 /// decorating the given <see cref="IAsyncUnitOfWork"/>.
 /// </summary>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> 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 AsyncUnitOfWorkExceptionHandler(IAsyncUnitOfWork inner, Func <TException, bool> handler)
     : base(inner)
 {
     Handler = handler ?? throw new ArgumentNullException(nameof(handler));
 }
예제 #27
0
 public FinishMeterReadProcessConsumer(IAsyncUnitOfWork asyncUnitOfWork, IRepository <Address, Guid> meterReadRepository)
 {
     _asyncUnitOfWork     = asyncUnitOfWork;
     _meterReadRepository = meterReadRepository;
 }
예제 #28
0
 /// <summary>
 /// Wraps the given <see cref="IAsyncUnitOfWork"/> in a <see cref="AsyncUnitOfWorkExceptionHandler{TException}"/>.
 /// </summary>
 /// <typeparam name="TException">"The type of exception to be handled.</typeparam>
 /// <param name="inner">The <see cref="IAsyncUnitOfWork"/> 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="AsyncUnitOfWorkExceptionHandler{TException}"/> wrapping the given <see cref="IAsyncUnitOfWork"/>.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="inner"/> is <c>null</c>.
 /// -or- <paramref name="handler"/> is <c>null</c>.</exception>
 public static IAsyncUnitOfWork Catch <TException>(this IAsyncUnitOfWork inner, Func <TException, bool> handler)
     where TException : Exception
 {
     return(new AsyncUnitOfWorkExceptionHandler <TException>(inner, handler));
 }
예제 #29
0
 public MeterMountedConsumer(IRepository <Address, Guid> addressRepository, IAsyncUnitOfWork asyncUnitOfWork)
 {
     _addressRepository = addressRepository;
     _asyncUnitOfWork   = asyncUnitOfWork;
 }
 public AddressAddedConsumer(IRepository <Address, Guid> repository, IAggregateFactory <Address, AddressFactoryInput, Guid> factory, IAsyncUnitOfWork asyncUnitOfWork)
 {
     _repository      = repository;
     _factory         = factory;
     _asyncUnitOfWork = asyncUnitOfWork;
 }