public async Task TestRealmsGetter() { const string connectionString = "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog=GuildTools;Integrated Security=True"; KeyedResourceManager manager = new KeyedResourceManager(); BlizzardApiSecrets blizzardSecrets = new BlizzardApiSecrets() { ClientId = this.config.GetValue <string>("BlizzardApiSecrets:ClientId"), ClientSecret = this.config.GetValue <string>("BlizzardApiSecrets:ClientSecret") }; HttpClient client = new HttpClient(); IMemoryCache memoryCache = new MemoryCache(new MemoryCacheOptions()); GuildToolsContext context = new GuildToolsContext(SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), connectionString).Options as DbContextOptions); IDatabaseCache dbCache = new DatabaseCache(context) as IDatabaseCache; IDataRepository repo = new DataRepository(context); IBlizzardService blizzardService = new BlizzardService(repo, this.config, client); RealmsCache cache = new RealmsCache(blizzardService, memoryCache, dbCache, manager); DateTime initial = DateTime.Now; var realms = await cache.GetRealms(EF.Models.Enums.GameRegionEnum.US); DateTime second = DateTime.Now; TimeSpan sinceInitial = second - initial; var realms2 = await cache.GetRealms(EF.Models.Enums.GameRegionEnum.US); DateTime third = DateTime.Now; TimeSpan sinceSecond = third - second; int x = 42; }
public RealmStoreById(IGuildService guildService, IMemoryCache memoryCache, GuildToolsContext context, IKeyedResourceManager resourceManager) { this.MemoryDuration = TimeSpan.FromDays(1); this.guildService = guildService; this.context = context; this.cache = new MemoryCachedDatabaseValue <StoredRealm>(memoryCache, this.MemoryDuration, resourceManager); }
public GuildStoreByName(IBlizzardService blizzardService, IMemoryCache memoryCache, GuildToolsContext context, IKeyedResourceManager resourceManager) { this.MemoryDuration = TimeSpan.FromDays(1); this.blizzardService = blizzardService; this.context = context; this.cache = new MemoryCachedDatabaseValueWithSource <StoredGuild>(memoryCache, this.MemoryDuration, resourceManager); }
public PlayerStoreByValue( IGuildService guildService, IMemoryCache memoryCache, GuildToolsContext context, IKeyedResourceManager resourceManager) { this.guildService = guildService; this.context = context; this.cache = new MemoryCachedDatabaseValueWithSource <StoredPlayer>(memoryCache, this.MemoryDuration, resourceManager); }
public async Task PlayerStoreTest() { const string connectionString = "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog=GuildTools;Integrated Security=True"; KeyedResourceManager manager = new KeyedResourceManager(); BlizzardApiSecrets blizzardSecrets = new BlizzardApiSecrets() { ClientId = this.config.GetValue <string>("BlizzardApiSecrets:ClientId"), ClientSecret = this.config.GetValue <string>("BlizzardApiSecrets:ClientSecret") }; IMemoryCache memoryCache = new MemoryCache(new MemoryCacheOptions()); GuildToolsContext context = new GuildToolsContext(SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), connectionString).Options as DbContextOptions); HttpClient client = new HttpClient(); IDataRepository repo = new DataRepository(context); IBlizzardService blizzardService = new BlizzardService(repo, this.config, client); PerRequestCallThrottler throttler = new PerRequestCallThrottler(TimeSpan.FromSeconds(1)); IGuildService guildService = new GuildService(blizzardService, throttler); int profileId = 1; GameRegion region = new GameRegion() { Id = 1, RegionName = "US" }; StoredRealm realm = context.StoredRealms.Include(a => a.Region).First(); StoredGuild guild = context.StoredGuilds.First(); PlayerStoreByValue playerStore = new PlayerStoreByValue(guildService, memoryCache, context, manager); DateTime initial = DateTime.Now; var realms = await playerStore.GetPlayerAsync("Kromp", realm, guild, profileId); DateTime second = DateTime.Now; TimeSpan sinceInitial = second - initial; var realms2 = await playerStore.GetPlayerAsync("Kromp", realm, guild, profileId); DateTime third = DateTime.Now; TimeSpan sinceSecond = third - second; var realms3 = await playerStore.GetPlayerAsync("Kromp", realm, guild, profileId); DateTime fourth = DateTime.Now; TimeSpan sinceThird = fourth - third; int x = 42; }
public async Task CachedStoredValueTest() { const string connectionString = "Data Source=(LocalDb)\\MSSQLLocalDB;Initial Catalog=GuildTools;Integrated Security=True"; KeyedResourceManager manager = new KeyedResourceManager(); BlizzardApiSecrets blizzardSecrets = new BlizzardApiSecrets() { ClientId = this.config.GetValue <string>("BlizzardApiSecrets:ClientId"), ClientSecret = this.config.GetValue <string>("BlizzardApiSecrets:ClientSecret") }; IMemoryCache memoryCache = new MemoryCache(new MemoryCacheOptions()); GuildToolsContext context = new GuildToolsContext(SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), connectionString).Options as DbContextOptions); HttpClient client = new HttpClient(); IDataRepository repo = new DataRepository(context); IBlizzardService blizzardService = new BlizzardService(repo, this.config, client); PerRequestCallThrottler throttler = new PerRequestCallThrottler(TimeSpan.FromSeconds(1)); IGuildService guildService = new GuildService(blizzardService, throttler); RealmStoreByValues store = new RealmStoreByValues(guildService, memoryCache, context, manager); DateTime initial = DateTime.Now; var realms = await store.GetRealmAsync("Burning Blade", EF.Models.Enums.GameRegionEnum.US); DateTime second = DateTime.Now; TimeSpan sinceInitial = second - initial; var realms2 = await store.GetRealmAsync("Burning Blade", EF.Models.Enums.GameRegionEnum.US); DateTime third = DateTime.Now; TimeSpan sinceSecond = third - second; var realms3 = await store.GetRealmAsync("Akama", EF.Models.Enums.GameRegionEnum.US); DateTime fourth = DateTime.Now; TimeSpan sinceThird = fourth - third; int x = 42; }
public DataRepository( GuildToolsContext context) { this.context = context; }
public DatabaseCache(GuildToolsContext context) { this.context = context; }
public AccountRepository( GuildToolsContext context) { this.context = context; }