public override IUserAuthRepository CreateAuthRepo() { var appSettings = new AppSettings(); var redisRepo = new RedisAuthRepository( new BasicRedisClientManager(appSettings.GetString("Redis.Host") ?? "localhost")); redisRepo.Clear(); InitTest(redisRepo); return(redisRepo); }
public void SetUp() { try { tests = new OAuthUserSessionTests(); var inMemoryRepo = new InMemoryAuthRepository(); inMemoryRepo.Clear(); userAuthRepositorys.Add(inMemoryRepo); var appSettings = new AppSettings(); var redisRepo = new RedisAuthRepository(new BasicRedisClientManager(new string[] { appSettings.GetString("Redis.Host") ?? "localhost" })); redisRepo.Clear(); userAuthRepositorys.Add(redisRepo); if (OAuthUserSessionTestsBase.UseSqlServer) { var connStr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\App_Data\auth.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"; var sqlServerFactory = new OrmLiteConnectionFactory(connStr, SqlServerOrmLiteDialectProvider.Instance); var sqlServerRepo = new OrmLiteAuthRepository(sqlServerFactory); sqlServerRepo.DropAndReCreateTables(); } else { var sqliteInMemoryRepo = new OrmLiteAuthRepository(dbFactory); using (var db = dbFactory.Open()) { db.DropAndCreateTable <UserAuth>(); db.DropAndCreateTable <UserAuthDetails>(); } sqliteInMemoryRepo.Clear(); userAuthRepositorys.Add(sqliteInMemoryRepo); var sqliteDbFactory = new OrmLiteConnectionFactory( "~/App_Data/auth.sqlite".MapProjectPath()); var sqliteDbRepo = new OrmLiteAuthRepository(sqliteDbFactory); sqliteDbRepo.CreateMissingTables(); userAuthRepositorys.Add(sqliteDbRepo); } } catch (Exception ex) { Console.WriteLine(ex.Message); throw; } }