public void Setup()
 {
     _logger             = Substitute.For <INpgLogger>();
     _authAdapter        = Substitute.For <IAuthAdapter>();
     _userRepository     = Substitute.For <IUserRepository>();
     _accountsController = new AccountsController(_logger, _authAdapter, _userRepository);
 }
Beispiel #2
0
        public void InitTestFixture()
        {
            var optionsBuilder = new DbContextOptionsBuilder <LoggingDatabaseContext>();

            optionsBuilder.UseNpgsql(TestConnectionString);
            _testDbContext     = new TestDatabaseContext(optionsBuilder.Options);
            _loggingRepository = new LoggingRepository(_testDbContext);
            _npgLogger         = new NpgLogger(_loggingRepository, LogLevel.All);
        }
Beispiel #3
0
        public void OneTimeSetUp()
        {
            _webAppFactory       = new TestWebApplicationFactory();
            _httpClient          = _webAppFactory.CreateClient();
            _testServiceProvider = _webAppFactory.GetTestServiceProvider();
            _mockLogger          = TestStartup.GetTestLogger();
            _mockAuthAdapter     = TestStartup.GetMockAuthAdapter();
            _mockCognitoHelper   = TestStartup.GetMockAuthHelper();
            var createDbContext = _webAppFactory.GetRemindMeDatabaseContext();

            createDbContext.ExecuteDatabaseMigration();
        }
Beispiel #4
0
        public override void ConfigureServices(IServiceCollection services)
        {
            base.ConfigureServices(services);

            var deployBucket = Configuration.GetSection("AWS").GetSection("S3")["DeployBucket"];
            var testDbConnectionStringKey = Configuration.GetSection("AWS").GetSection("RDS")["AppDbConnectionStringKey"];

            var provider       = services.BuildServiceProvider();
            var storageAdapter = provider.GetRequiredService <IStorageAdapter>();

            _connectionString = storageAdapter.GetObjectAsync(deployBucket, testDbConnectionStringKey).Result;
            services
            .AddEntityFrameworkNpgsql()
            .AddDbContext <TestDatabaseContext>(options =>
                                                options.UseNpgsql(_connectionString));

            var mockLogger = Substitute.For <INpgLogger>();

            services.AddSingleton(mockLogger);
            _mockLogger = mockLogger;

            var mockAuthAdapter = Substitute.For <IAuthAdapter>();

            services.AddSingleton(mockAuthAdapter);
            _mockAuthAdapter = mockAuthAdapter;

            var mockCognitoHelper = Substitute.For <IAwsCognitoAdapterHelper>();

            services.AddSingleton(mockCognitoHelper);
            _mockCognitoHelper = mockCognitoHelper;

            services.AddMvc()
            .AddApplicationPart(typeof(AccountsController).Assembly);

            _services = services;
        }
Beispiel #5
0
 public AccountsController(INpgLogger logger, IAuthAdapter authAdapter, IUserRepository userRepository)
 {
     _logger         = logger;
     _authAdapter    = authAdapter;
     _userRepository = userRepository;
 }
Beispiel #6
0
 public void Setup()
 {
     _loggingResitory = Substitute.For <ILoggingRepository>();
     _defaultLogger   = new NpgLogger(_loggingResitory, LogLevel.All);
 }
Beispiel #7
0
 public RemindersController(IReminderRepository reminderRepository, IUserRepository userRepository, INpgLogger logger)
 {
     _reminderRepository = reminderRepository;
     _userRepository     = userRepository;
     _logger             = logger;
 }