コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MathManager"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 public MathManager(
     FvectContext dbContext,
     ILogger <MathManager> logger)
 {
     this.dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     this.logger    = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthenticationFlowTest"/> class.
        /// </summary>
        /// <param name="outputHelper">The test output helper.</param>
        public AuthenticationFlowTest(ITestOutputHelper outputHelper)
        {
            this.outputHelper             = outputHelper;
            this.testDatabase             = new TestDatabase(outputHelper);
            this.dbContext                = this.testDatabase.CreateContext();
            this.identityInstance         = IdentityTestHelper.CreateInstance(this.testDatabase, this.outputHelper);
            this.usedHttpContext          = new DefaultHttpContext();
            this.httpConctextAccessorMock = new Mock <IHttpContextAccessor>();
            this.jwtCrypoMock             = new Mock <IJwtCryptoProvider>();
            this.momentMock               = MomentTestHelper.CreateMomentMock();
            this.optionsMonitorMock       = OptionsTestHelper.CreateBackendOptionsMock();
            this.randomGenerator          = new SecureRandomGenerator();
            this.loggerFactory            = LoggingTestHelper.CreateLoggerFactory(this.outputHelper);

            this.httpConctextAccessorMock.SetupGet(m => m.HttpContext).Returns(this.usedHttpContext);

            this.jwtCrypoMock.SetupGet(c => c.Algorithm).Returns(SigningAlgorithm);
            this.jwtCrypoMock.SetupGet(c => c.SecurityKey).Returns(SigningKey);

            this.authenticationFlow = new AuthenticationFlow(
                this.httpConctextAccessorMock.Object,
                this.jwtCrypoMock.Object,
                this.identityInstance.UserManager,
                this.dbContext,
                this.randomGenerator,
                this.momentMock.Object,
                this.optionsMonitorMock.Object,
                this.loggerFactory.CreateLogger <AuthenticationFlow>());
        }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceManagerBase{TEntity, TImpl}"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 protected ResourceManagerBase(
     FvectContext dbContext,
     ILogger <TImpl> logger)
 {
     this.DbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     this.Logger    = logger ?? throw new ArgumentNullException(nameof(logger));
     this.DbSet     = dbContext.Set <TEntity>();
 }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthManager"/> class.
 /// </summary>
 /// <param name="userManager">The user manager.</param>
 /// <param name="dbContext">The database context.</param>
 /// <param name="moment">The moment.</param>
 public AuthManager(
     UserManager <AppUser> userManager,
     FvectContext dbContext,
     IMoment moment)
 {
     this.userManager = userManager;
     this.dbContext   = dbContext;
     this.moment      = moment;
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeoMapImageCacheCleaningTask"/> class.
 /// </summary>
 /// <param name="dbContext">The database context to use.</param>
 /// <param name="optionsProvider">The options provider to use.</param>
 /// <param name="logger">The logger to use.</param>
 public GeoMapImageCacheCleaningTask(
     FvectContext dbContext,
     IOptionsMonitor <BackendOptions> optionsProvider,
     ILogger <GeoMapImageCacheCleaningTask> logger)
 {
     this.dbContext       = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     this.optionsProvider = optionsProvider ?? throw new ArgumentNullException(nameof(optionsProvider));
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CachedMapImageRetriever"/> class.
 /// </summary>
 /// <param name="dbContext">The database context to use.</param>
 /// <param name="inner">The inner map image retriever.</param>
 /// <param name="optionsProvider">The options provider.</param>
 /// <param name="logger">The logger.</param>
 public CachedMapImageRetriever(
     FvectContext dbContext,
     IMapImageRetriever inner,
     IOptionsMonitor <BackendOptions> optionsProvider,
     ILogger <CachedMapImageRetriever> logger)
     : base(inner)
 {
     this.OnInnerRetrievedAsyncHandler = this.HandleRetrievedFromInner;
     this.dbContext       = dbContext ?? throw new ArgumentNullException(nameof(logger));
     this.optionsProvider = optionsProvider ?? throw new ArgumentNullException(nameof(optionsProvider));
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DevController"/> class.
        /// </summary>
        /// <param name="hostEnvironment">The current host environment.</param>
        /// <param name="dbContext">The db context.</param>
        /// <exception cref="InvalidOperationException">
        /// When the current environment is not the development environment.
        /// </exception>
        public DevController(
            IHostEnvironment hostEnvironment,
            FvectContext dbContext)
        {
            if (!(hostEnvironment ?? throw new ArgumentNullException(nameof(hostEnvironment))).IsDevelopment())
            {
                throw new InvalidOperationException(
                          $"{nameof(DevController)} operations may only be invoked in a development environment.");
            }

            this.dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
        }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationFlow"/> class.
 /// </summary>
 /// <param name="httpContextAccessor">The context accessor.</param>
 /// <param name="jwtCrytpoProvider">The crypto provider.</param>
 /// <param name="userManager">The user manager.</param>
 /// <param name="dbContext">The database context.</param>
 /// <param name="rngGenerator">The random generator.</param>
 /// <param name="moment">The current moment provider.</param>
 /// <param name="options">The options.</param>
 /// <param name="logger">The logger.</param>
 public AuthenticationFlow(
     IHttpContextAccessor httpContextAccessor,
     IJwtCryptoProvider jwtCrytpoProvider,
     UserManager <AppUser> userManager,
     FvectContext dbContext,
     ISecureRandomGenerator rngGenerator,
     IMoment moment,
     IOptionsMonitor <BackendOptions> options,
     ILogger <AuthenticationFlow> logger)
 {
     this.httpContextAccessor = httpContextAccessor ?? throw new ArgumentNullException(nameof(httpContextAccessor));
     this.jwtCrytpoProvider   = jwtCrytpoProvider ?? throw new ArgumentNullException(nameof(jwtCrytpoProvider));
     this.userManager         = userManager ?? throw new ArgumentNullException(nameof(userManager));
     this.dbContext           = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     this.rngGenerator        = rngGenerator ?? throw new ArgumentNullException(nameof(rngGenerator));
     this.moment  = moment ?? throw new ArgumentNullException(nameof(moment));
     this.options = options ?? throw new ArgumentNullException(nameof(options));
     this.logger  = logger ?? throw new ArgumentNullException(nameof(logger));
 }
コード例 #9
0
        public void ModelDoesNotContainPendingChanges()
        {
            // Do not use the test database, the SQL Server model provider must be
            // used as that is the model provider that is used for scaffolding migrations.
            using var ctx = new FvectContext(
                      new DbContextOptionsBuilder <FvectContext>()
                      .UseSqlServer(DummyConnectionString)
                      .Options);

            var modelDiffer        = ctx.GetService <IMigrationsModelDiffer>();
            var migrationsAssembly = ctx.GetService <IMigrationsAssembly>();

            var pendingModelChanges = modelDiffer
                                      .GetDifferences(
                migrationsAssembly.ModelSnapshot?.Model,
                ctx.Model);

            pendingModelChanges
            .Should()
            .BeEmpty(
                because:
                "the current model state should be equal to the state that results from all the migrations combined (try scaffolding a migration)");
        }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="UserProfileManager"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 public UserProfileManager(
     FvectContext dbContext,
     ILogger <UserProfileManager> logger)
     : base(dbContext, logger)
 {
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AnswerManager"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 public AnswerManager(
     FvectContext dbContext,
     ILogger <AnswerManager> logger)
     : base(dbContext, logger)
 {
 }
コード例 #12
0
 private MathManager CreateMathManager(FvectContext dbContext)
 => new MathManager(
     dbContext,
     LoggingTestHelper.CreateLogger <MathManager>(this.outputHelper));
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="QuestionManager"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 public QuestionManager(
     FvectContext dbContext,
     ILogger <QuestionManager> logger)
     : base(dbContext, logger)
 {
 }
コード例 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TeacherManager"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 public TeacherManager(
     FvectContext dbContext,
     ILogger <TeacherManager> logger)
     : base(dbContext, logger)
 {
 }
コード例 #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StudentGroupManager"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 public StudentGroupManager(
     FvectContext dbContext,
     ILogger <StudentGroupManager> logger)
     : base(dbContext, logger)
 {
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LevelManager"/> class.
 /// </summary>
 /// <param name="dbContext">The database context.</param>
 /// <param name="logger">The logger.</param>
 public LevelManager(
     FvectContext dbContext,
     ILogger <LevelManager> logger)
     : base(dbContext, logger)
 {
 }