Beispiel #1
0
 public void Using_data_context_is_an_option()
 {
     var cs = CreateConnectionString();
     using (var db = new SqliteDataContext(cs))
     {
         Assert.IsNotNull(db);
     }
 }
        public void Data_context_instantiates()
        {
            var cs = _fixture.CreateConnectionString();

            using (var db = new SqliteDataContext(cs))
            {
                Assert.NotNull(db);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Configures the Data Context of the aplication with a SQLite database.
        /// </summary>
        /// <param name="services">The <see cref="IServiceCollection"/> implementation of the Asp.Net Core application.</param>
        /// <returns>The configured <see cref="IServiceCollection"/> implementation of the Asp.Net Core application.</returns>
        public static IServiceCollection AddSqliteDataContext(this IServiceCollection services)
        {
            var connectionString = services.BuildServiceProvider()
                                   .GetService <IConfiguration>()
                                   .GetConnectionString("Sqlite");
            var dataContext = new SqliteDataContext(connectionString);

            services.AddSingleton <DataContext>(dataContext);
            return(services);
        }
Beispiel #4
0
        public UserServiceTest()
        {
            var passwordHelperLocalizer = Substitute.For<IStringLocalizer<PasswordHelper>>();
            passwordHelperLocalizer[Arg.Any<string>()].Returns(p => new LocalizedString((string)p[0], (string)p[0]));

            _passwordHelper = new PasswordHelper(passwordHelperLocalizer);
            _totpService = new TimeBasedOneTimePasswordNuGetService();

            var dataHelper = new DataHelper();
            _db = dataHelper.CreateDbContext(_passwordHelper);
            _factory = dataHelper.Factory;

            _service = new UserService(_db, _totpService);
        }
Beispiel #5
0
 public FeedController(ILogger <FeedController> logger,
                       IRssFeedRepository rssFeedRepository,
                       IRefreshRssFeed refreshRssFeed,
                       IFeedParser feedParser,
                       IHttpClientFactory clientFactory,
                       SqliteDataContext context)
 {
     _logger            = logger;
     _rssFeedRepository = rssFeedRepository;
     _refreshRssFeed    = refreshRssFeed;
     _feedParser        = feedParser;
     _clientFactory     = clientFactory;
     _context           = context;
 }
Beispiel #6
0
 public UsersController(SqliteDataContext context)
 {
     _context = context;
 }
 public Factory(SqliteDataContext context, IPasswordHelper passwordHelper)
 {
     Context         = context;
     _passwordHelper = passwordHelper;
     Context.SaveChanges();
 }
Beispiel #8
0
 public AccountController(SqliteDataContext context, ITokenService tokenService)
 {
     _tokenService = tokenService;
     _context      = context;
 }