public DbDependentTestApplication( IServiceProvider serviceProvider, SeededEntities seededEntities ) { _rootServiceProvider = serviceProvider; Services = new TestApplicationServiceScope(_rootServiceProvider); SeededEntities = seededEntities; TestData = new TestDataHelper(_rootServiceProvider, SeededEntities); Mocks = new MockServicesHelper(Services); }
/// <summary> /// Creates a new authorized task using the <see cref="TestAuthorizedTaskType1"/> /// task type. /// </summary> /// <param name="userId">Id of the user to scope the task to.</param> /// <param name="authorizedTaskTypeCode">The <see cref="IAuthorizedTaskTypeDefinition.AuthorizedTaskTypeCode"/> to group tasks by.</param> /// <param name="configuration">Optional configuration action to customize the command.</param> public async Task <AddAuthorizedTaskCommand> AddAsync( int userId, DateTime?mockDate, Action <AddAuthorizedTaskCommand> configuration = null ) { var command = CreateAddCommand(userId, configuration); using var scope = _serviceProvider.CreateScope(); var contentRepository = scope.ServiceProvider.GetRequiredService <IAdvancedContentRepository>(); if (mockDate.HasValue) { MockServicesHelper.MockDateTime(scope.ServiceProvider, mockDate.Value); } await contentRepository .AuthorizedTasks() .AddAsync(command); return(command); }