private IList <TaskEntity> CreateTasks(IAmiUnitOfWork context, DateTime createdDate) { IList <TaskEntity> tasks = new List <TaskEntity>(); for (int i = 0; i < 1000; i++) { var task = new TaskEntity() { Id = Guid.NewGuid(), CreatedDate = createdDate, ModifiedDate = DateTime.UtcNow, Status = (int)Domain.Enums.TaskStatus.Processing }; tasks.Add(task); context.TaskRepository.Add(task); } context.SaveChanges(); var entities = context.TaskRepository.GetQuery(e => e.CreatedDate == createdDate && e.Status == (int)Domain.Enums.TaskStatus.Processing); Assert.AreEqual(1000, entities.Count()); return(tasks); }
/// <summary> /// Initializes a new instance of the <see cref="UserStore{TUser}"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="constants">The application constants.</param> /// <param name="idGenerator">The generator for unique identifiers.</param> public UserStore(IAmiUnitOfWork context, IApplicationConstants constants, IIdGenerator idGenerator) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.constants = constants ?? throw new ArgumentNullException(nameof(constants)); this.idGenerator = idGenerator ?? throw new ArgumentNullException(nameof(idGenerator)); repository = context.UserRepository as IRepository <TUser>; }
private void UpdateCreatedDate(IAmiUnitOfWork context, ObjectModel model, DateTime date) { var entity = context.ObjectRepository.GetFirstOrDefault(e => e.Id == Guid.Parse(model.Id)); entity.CreatedDate = date.ToUniversalTime(); context.ObjectRepository.Update(entity); context.SaveChanges(); }
/// <summary> /// Initializes a new instance of the <see cref="QueryHandlerModule"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="constants">The application constants.</param> /// <param name="principalProvider">The principal provider.</param> /// <param name="serializer">The JSON serializer.</param> public QueryHandlerModule( IAmiUnitOfWork context, IApplicationConstants constants, ICustomPrincipalProvider principalProvider, IDefaultJsonSerializer serializer) { Context = context ?? throw new ArgumentNullException(nameof(context)); Constants = constants ?? throw new ArgumentNullException(nameof(constants)); PrincipalProvider = principalProvider ?? throw new ArgumentNullException(nameof(principalProvider)); Serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
/// <summary> /// Initializes a new instance of the <see cref="GatewayService"/> class. /// </summary> /// <param name="builder">The builder for gateway group names.</param> /// <param name="context">The context.</param> /// <param name="constants">The application constants.</param> /// <param name="gatewayObserverService">The gateway observer service.</param> public GatewayService( IGatewayGroupNameBuilder builder, IAmiUnitOfWork context, IApplicationConstants constants, IGatewayObserverService gatewayObserverService) { Builder = builder ?? throw new ArgumentNullException(nameof(builder)); this.context = context ?? throw new ArgumentNullException(nameof(context)); this.constants = constants ?? throw new ArgumentNullException(nameof(constants)); this.gatewayObserverService = gatewayObserverService ?? throw new ArgumentNullException(nameof(gatewayObserverService)); }
/// <summary> /// Initializes a new instance of the <see cref="CreateCommandHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="idGenService">The service to generate unique identifiers.</param> /// <param name="serializer">The JSON serializer.</param> /// <param name="queue">The task queue.</param> public CreateCommandHandler( IAmiUnitOfWork context, IIdGenService idGenService, IDefaultJsonSerializer serializer, ITaskQueue queue) : base() { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.idGenService = idGenService ?? throw new ArgumentNullException(nameof(idGenService)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); this.queue = queue ?? throw new ArgumentNullException(nameof(queue)); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessCommandHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="idGenService">The service to generate unique identifiers.</param> /// <param name="serializer">The JSON serializer.</param> /// <param name="imageService">The image service.</param> public ProcessCommandHandler( IAmiUnitOfWork context, IIdGenService idGenService, IDefaultJsonSerializer serializer, IImageService imageService) : base() { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.idGenService = idGenService ?? throw new ArgumentNullException(nameof(idGenService)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); this.imageService = imageService ?? throw new ArgumentNullException(nameof(imageService)); }
/// <summary> /// Initializes a new instance of the <see cref="CommandHandlerModule"/> class. /// </summary> /// <param name="auditService">The auditing service.</param> /// <param name="context">The context.</param> /// <param name="eventService">The events service.</param> /// <param name="gateway">The gateway service.</param> /// <param name="authService">The identity service.</param> /// <param name="principalProvider">The principal provider.</param> public CommandHandlerModule( IAuditService auditService, IAmiUnitOfWork context, IEventService eventService, IGatewayService gateway, IAuthService authService, ICustomPrincipalProvider principalProvider) { Audit = auditService ?? throw new ArgumentNullException(nameof(auditService)); Context = context ?? throw new ArgumentNullException(nameof(context)); Events = eventService ?? throw new ArgumentNullException(nameof(eventService)); Gateway = gateway ?? throw new ArgumentNullException(nameof(gateway)); AuthService = authService ?? throw new ArgumentNullException(nameof(authService)); PrincipalProvider = principalProvider ?? throw new ArgumentNullException(nameof(principalProvider)); }
/// <summary> /// Initializes a new instance of the <see cref="GetImageQueryHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="configuration">The configuration.</param> /// <param name="fileSystemStrategy">The file system strategy.</param> public GetImageQueryHandler( IAmiUnitOfWork context, IAmiConfigurationManager configuration, IFileSystemStrategy fileSystemStrategy) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); if (fileSystemStrategy == null) { throw new ArgumentNullException(nameof(fileSystemStrategy)); } fileSystem = fileSystemStrategy.Create(configuration.WorkingDirectory); }
/// <summary> /// Initializes a new instance of the <see cref="ResultDownloader"/> class. /// </summary> /// <param name="mediator">The mediator.</param> /// <param name="context">The context.</param> /// <param name="configuration">The configuration.</param> /// <param name="writer">The writer.</param> /// <param name="fileSystemStrategy">The file system strategy.</param> public ResultDownloader( IMediator mediator, IAmiUnitOfWork context, IAppConfiguration configuration, IArchiveWriter writer, IFileSystemStrategy fileSystemStrategy) { this.mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); this.context = context ?? throw new ArgumentNullException(nameof(context)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); this.writer = writer ?? throw new ArgumentNullException(nameof(writer)); if (fileSystemStrategy == null) { throw new ArgumentNullException(nameof(fileSystemStrategy)); } fileSystem = fileSystemStrategy.Create(configuration.Options.WorkingDirectory); }
/// <summary> /// Initializes a new instance of the <see cref="CreateCommandHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="idGenService">The service to generate unique identifiers.</param> /// <param name="constants">The application constants.</param> /// <param name="configuration">The configuration.</param> /// <param name="fileSystemStrategy">The file system strategy.</param> public CreateCommandHandler( IAmiUnitOfWork context, IIdGenService idGenService, IApplicationConstants constants, IAmiConfigurationManager configuration, IFileSystemStrategy fileSystemStrategy) : base() { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.idGenService = idGenService ?? throw new ArgumentNullException(nameof(idGenService)); this.constants = constants ?? throw new ArgumentNullException(nameof(constants)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); if (fileSystemStrategy == null) { throw new ArgumentNullException(nameof(fileSystemStrategy)); } fileSystem = fileSystemStrategy.Create(configuration.WorkingDirectory); }
/// <summary> /// Initializes a new instance of the <see cref="ProcessCommandHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="idGenService">The service to generate unique identifiers.</param> /// <param name="serializer">The JSON serializer.</param> /// <param name="mediator">The mediator.</param> /// <param name="configuration">The configuration.</param> /// <param name="fileSystemStrategy">The file system strategy.</param> public ProcessCommandHandler( IAmiUnitOfWork context, IIdGenService idGenService, IDefaultJsonSerializer serializer, IMediator mediator, IAmiConfigurationManager configuration, IFileSystemStrategy fileSystemStrategy) : base() { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.idGenService = idGenService ?? throw new ArgumentNullException(nameof(idGenService)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); this.mediator = mediator ?? throw new ArgumentNullException(nameof(mediator)); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); if (fileSystemStrategy == null) { throw new ArgumentNullException(nameof(fileSystemStrategy)); } fileSystem = fileSystemStrategy.Create(configuration.WorkingDirectory); }
private IList <WebhookEntity> CreateWebhooks(IMediator mediator, IAmiUnitOfWork uow, CancellationToken ct) { IList <WebhookEntity> entities = new List <WebhookEntity>(); // Webhook 1 var command1 = new CreateWebhookCommand() { ApiVersion = "1.0.0", EnabledEvents = new HashSet <string>() { EventType.TaskUpdated.ToString(), EventType.TaskCreated.ToString() }, Secret = "1234", Url = "http://localhost/webhook1" }; var result1 = mediator.Send(command1, ct).Result; var entity1 = uow.WebhookRepository.GetFirstOrDefault(e => e.Id == new Guid(result1.Id)); entities.Add(entity1); // Webhook 2 var command2 = new CreateWebhookCommand() { ApiVersion = "1.0.0", EnabledEvents = new HashSet <string>() { "*" }, Secret = "1234", Url = "http://localhost/webhook2" }; var result2 = mediator.Send(command2, ct).Result; var entity2 = uow.WebhookRepository.GetFirstOrDefault(e => e.Id == new Guid(result2.Id)); entities.Add(entity2); // Change user var principal1 = TestExecutionContext.CurrentContext.CurrentPrincipal; TestExecutionContext.CurrentContext.CurrentPrincipal = new MockPrincipal( SHARED_GUID_2, new RoleType[] { RoleType.Administrator }); // Webhook 3 var command3 = new CreateWebhookCommand() { ApiVersion = "1.0.0", EnabledEvents = new HashSet <string>() { EventType.TaskUpdated.ToString(), EventType.TaskCreated.ToString() }, Secret = "1234", Url = "http://localhost/webhook3" }; var result3 = mediator.Send(command3, ct).Result; var entity3 = uow.WebhookRepository.GetFirstOrDefault(e => e.Id == new Guid(result3.Id)); entities.Add(entity3); // Change user TestExecutionContext.CurrentContext.CurrentPrincipal = principal1; return(entities); }
/// <summary> /// Initializes a new instance of the <see cref="RoleStore{TRole}"/> class. /// </summary> /// <param name="context">The context.</param> public RoleStore(IAmiUnitOfWork context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); }
/// <summary> /// Initializes a new instance of the <see cref="UpdateCommandHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="serializer">The JSON serializer.</param> public UpdateCommandHandler(IAmiUnitOfWork context, IDefaultJsonSerializer serializer) : base() { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
/// <summary> /// Initializes a new instance of the <see cref="GetByIdQueryHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="constants">The application constants.</param> /// <param name="serializer">The JSON serializer.</param> public GetByIdQueryHandler(IAmiUnitOfWork context, IApplicationConstants constants, IDefaultJsonSerializer serializer) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.constants = constants ?? throw new ArgumentNullException(nameof(constants)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
/// <summary> /// Initializes a new instance of the <see cref="GetObjectsQueryHandler"/> class. /// </summary> /// <param name="context">The context.</param> /// <param name="serializer">The JSON serializer.</param> public GetObjectsQueryHandler(IAmiUnitOfWork context, IDefaultJsonSerializer serializer) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); }
/// <summary> /// Initializes a new instance of the <see cref="RepositoryFactory"/> class. /// </summary> /// <param name="context">The context.</param> public RepositoryFactory(IAmiUnitOfWork context) { this.context = context ?? throw new ArgumentNullException(nameof(context)); }