public void AggregateSaved_NotBeNullOrEmpty() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); using var client = new SeriesClient(settings); var gauge = client.CreateAggregateGauge("test"); gauge.Record(400); gauge.Record(300); gauge.Record(420); gauge.Record(410); gauge.Record(200); gauge.Record(324); gauge.Record(542); gauge.Record(401); gauge.Record(434); gauge.Record(290); var id = gauge.CommitAggregate(); id.Should().NotBeNullOrEmpty(); }
/// <summary> /// Initializes a new instance of the <see cref="GoodreadsClient"/> class. /// Use this constructor if you already have OAuth permissions for the user. /// </summary> /// <param name="apiKey">Your Goodreads API key.</param> /// <param name="apiSecret">Your Goodreads API secret.</param> /// <param name="accessToken">The user's OAuth access token.</param> /// <param name="accessSecret">The user's OAuth access secret.</param> public GoodreadsClient(string apiKey, string apiSecret, string accessToken, string accessSecret) { var client = new RestClient(new Uri(GoodreadsUrl)) { UserAgent = "goodreads-dotnet" }; client.AddDefaultParameter("key", apiKey, ParameterType.QueryString); client.AddDefaultParameter("format", "xml", ParameterType.QueryString); var apiCredentials = new ApiCredentials(client, apiKey, apiSecret, accessToken, accessSecret); // Setup the OAuth authenticator if they have passed on the appropriate tokens if (!string.IsNullOrWhiteSpace(accessToken) && !string.IsNullOrWhiteSpace(accessSecret)) { client.Authenticator = OAuth1Authenticator.ForProtectedResource( apiKey, apiSecret, accessToken, accessSecret); } Connection = new Connection(client, apiCredentials); Authors = new AuthorsClient(Connection); Books = new BooksClient(Connection); Shelves = new ShelvesClient(Connection); Users = new UsersClient(Connection); Reviews = new ReviewsClient(Connection); Series = new SeriesClient(Connection); }
protected virtual void InitRestClients() { RestClient = new RestClient(RootUrl + "api/"); RestClient.AddDefaultHeader("Authentication", ApiKey); RestClient.AddDefaultHeader("X-Api-Key", ApiKey); Blacklist = new ClientBase <BlacklistResource>(RestClient, ApiKey); Commands = new CommandClient(RestClient, ApiKey); DownloadClients = new DownloadClientClient(RestClient, ApiKey); Episodes = new EpisodeClient(RestClient, ApiKey); History = new ClientBase <HistoryResource>(RestClient, ApiKey); HostConfig = new ClientBase <HostConfigResource>(RestClient, ApiKey, "config/host"); Indexers = new IndexerClient(RestClient, ApiKey); Logs = new LogsClient(RestClient, ApiKey); NamingConfig = new ClientBase <NamingConfigResource>(RestClient, ApiKey, "config/naming"); Notifications = new NotificationClient(RestClient, ApiKey); Profiles = new ClientBase <ProfileResource>(RestClient, ApiKey); Releases = new ReleaseClient(RestClient, ApiKey); ReleasePush = new ReleasePushClient(RestClient, ApiKey); RootFolders = new ClientBase <RootFolderResource>(RestClient, ApiKey); Series = new SeriesClient(RestClient, ApiKey); Tags = new ClientBase <TagResource>(RestClient, ApiKey); WantedMissing = new ClientBase <EpisodeResource>(RestClient, ApiKey, "wanted/missing"); WantedCutoffUnmet = new ClientBase <EpisodeResource>(RestClient, ApiKey, "wanted/cutoff"); }
public void DisposeCommitsAggregate_Be0() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); using var client = new SeriesClient(settings); var gauge = client.CreateAggregateGauge("test", 20); gauge.Record(400); gauge.Record(300); gauge.Record(420); gauge.Record(410); gauge.Record(200); gauge.Record(324); gauge.Record(542); gauge.Record(401); gauge.Record(434); gauge.Record(290); gauge.Dispose(); gauge.GetCurrentBatchCount().Should().Be(0); }
public async Task ReturnsSeries() { var series = await SeriesClient.GetListByAuthorId(38550); Assert.NotNull(series); Assert.True(series.Count > 0); }
public async Task ReturnsSeries() { var series = await SeriesClient.GetListByWorkId(8134945); Assert.NotNull(series); Assert.True(series.Count > 0); }
public async Task BatchIsNotSavedWhenBatchIsNotFullAsync_BeEmpty() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); await using var client = new SeriesClient(settings); var gauge = client.CreateMetricGauge("test", 20); await gauge.RecordAsync(400); await gauge.RecordAsync(300); await gauge.RecordAsync(420); await gauge.RecordAsync(410); await gauge.RecordAsync(200); await gauge.RecordAsync(324); await gauge.RecordAsync(542); await gauge.RecordAsync(401); await gauge.RecordAsync(434); await gauge.RecordAsync(290); var save = await gauge.RecordAsync(290); save.Should().BeEmpty(); }
public void BatchRecordsAreSaved_Be10() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); using var client = new SeriesClient(settings); var gauge = client.CreateMetricGauge("test"); gauge.Record(400); gauge.Record(300); gauge.Record(420); gauge.Record(410); gauge.Record(200); gauge.Record(324); gauge.Record(542); gauge.Record(401); gauge.Record(434); gauge.Record(290); var ids = gauge.FlushBatch(); ids.Count().Should().Be(10); }
public TvDbClient(HttpClient client, TvDBTokenAccessor tokenAccessor, IOptions <TvdbClientOptions> options) { Series = new SeriesClient(client); Search = new SearchClient(client); Episodes = new EpisodesClient(client); Updates = new UpdatesClient(client); Languages = new LanguagesClient(client); Users = new UsersClient(client); Authentication = new AuthenticationClient(client, tokenAccessor, options); }
public async Task ReturnsSeriesInformation() { var expectedSeriesId = 49075; var series = await SeriesClient.GetById(expectedSeriesId); Assert.NotNull(series); Assert.Equal(expectedSeriesId, series.Id); Assert.NotNull(series.Works); Assert.True(series.Works.Count > 0); }
public ComicVineClient(string apiKey, string?userAgent = null) { HttpMessenger = new HttpMessenger(userAgent); HttpConnection = new HttpConnection(HttpMessenger, apiKey); ApiConnection = new ApiConnection(HttpConnection); Character = new CharacterClient(ApiConnection); Series = new SeriesClient(ApiConnection); Issue = new IssueClient(ApiConnection); Volume = new VolumeClient(ApiConnection); Search = new SearchClient(ApiConnection); }
private void InitRestClients() { RestClient = new RestClient("http://localhost:8989/api"); Series = new SeriesClient(RestClient, _runner.ApiKey); Releases = new ReleaseClient(RestClient, _runner.ApiKey); RootFolders = new ClientBase<RootFolderResource>(RestClient, _runner.ApiKey); Commands = new ClientBase<CommandResource>(RestClient, _runner.ApiKey); History = new ClientBase<HistoryResource>(RestClient, _runner.ApiKey); Indexers = new IndexerClient(RestClient, _runner.ApiKey); Episodes = new EpisodeClient(RestClient, _runner.ApiKey); NamingConfig = new ClientBase<NamingConfigResource>(RestClient, _runner.ApiKey, "config/naming"); }
public async Task RecordsAreSavedWhenForcePushedAsync_NotBeNull() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); using var client = new SeriesClient(settings); var id = await client.CreateMetricGauge("test").RecordAsync(400, forcePush: true); id.Should().NotBeNull(); }
private void InitRestClients() { RestClient = new RestClient("http://localhost:8989/api"); Series = new SeriesClient(RestClient); Releases = new ReleaseClient(RestClient); RootFolders = new ClientBase <RootFolderResource>(RestClient); Commands = new ClientBase <CommandResource>(RestClient); History = new ClientBase <HistoryResource>(RestClient); Indexers = new IndexerClient(RestClient); Episodes = new EpisodeClient(RestClient); NamingConfig = new ClientBase <NamingConfigResource>(RestClient, "config/naming"); }
private void InitRestClients() { RestClient = new RestClient(RootUrl + "api/"); Series = new SeriesClient(RestClient, _runner.ApiKey); Releases = new ReleaseClient(RestClient, _runner.ApiKey); RootFolders = new ClientBase <RootFolderResource>(RestClient, _runner.ApiKey); Commands = new ClientBase <CommandResource>(RestClient, _runner.ApiKey); History = new ClientBase <HistoryResource>(RestClient, _runner.ApiKey); Indexers = new IndexerClient(RestClient, _runner.ApiKey); Episodes = new EpisodeClient(RestClient, _runner.ApiKey); NamingConfig = new ClientBase <NamingConfigResource>(RestClient, _runner.ApiKey, "config/naming"); Notifications = new NotificationClient(RestClient, _runner.ApiKey); }
public TheTvDbClient(string apiKey, string userkey = "", string username = "") { HttpClient = new RestClient("https://api.thetvdb.com/"); Language = Languages.En; _authenticationClient = new AuthenticationClient(this); _authenticationClient.Login(apiKey, userkey, username); SearchClient = new SearchClient(this); SeriesClient = new SeriesClient(this); EpisodeClient = new EpisodeClient(this); UpdateClient = new UpdateClient(this); }
public async Task CallingDisposeWhenBatchIsEmptyDoesntErrorAsync_NotThrow() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); Func <Task> act = async() => { await using (var client = new SeriesClient(settings)) { client.CreateMetricGauge("test", 20); } }; await act.Should().NotThrowAsync <ArgumentException>(); }
public void CanOnlyStopWhenTimerRunning_ThrowsInvalidOperationException() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); using var client = new SeriesClient(settings); var gauge = client.CreateAggregateGauge("test"); Action act = () => { gauge.StopTimer(); }; act.Should().Throw <InvalidOperationException>(); }
public TVDBClient( HttpClient client, IOptions <TVDBClientOptions> options, TVDBContext context) { if (!options.Value.ShareContextBetweenClients) { // If we don't want to share the context, we are creating one just for this client context = new TVDBContext(); } Series = new SeriesClient(client, options, context); Search = new SearchClient(client, options, context); Episodes = new EpisodesClient(client, options, context); Updates = new UpdatesClient(client, options, context); Languages = new LanguagesClient(client, options, context); Users = new UsersClient(client, options, context); Authentication = new AuthenticationClient(client, options, context); }
public async Task DisposeAsyncFlushesBatch_Be0() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); await using var client = new SeriesClient(settings); var gauge = client.CreateMetricGauge("test", 20); await gauge.RecordAsync(400); await gauge.RecordAsync(300); await gauge.DisposeAsync(); gauge.GetCurrentBatchCount().Should().Be(0); }
public void DataCommitedWhenTimerTicks_Be0() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); using var client = new SeriesClient(settings); var gauge = client.CreateAggregateGauge("test"); gauge.StartTimer(TimeSpan.FromSeconds(2)); gauge.Record(400); Thread.Sleep(TimeSpan.FromSeconds(3)); gauge.GetCurrentBatchCount().Should().Be(0); }
public async Task ForcePushOnlyCommitsPassedDataAsync_NotBeNull() { var settings = new ConnectionSettings(new Uri(JsonConvert.DeserializeObject <Config>(File.ReadAllText(Path.Combine(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.Parent.Parent.FullName, "es.json"))).ElasticSearchUrl)); settings.DefaultIndex("elasticseriestest"); using var client = new SeriesClient(settings); var gauge = client.CreateMetricGauge("test"); await gauge.RecordAsync(400); var id = await gauge.RecordAsync(410, forcePush : true); using (var scope = new AssertionScope()) { id.Should().NotBeNull(); gauge.GetCurrentBatchCount().Should().Be(1); } }
protected virtual void InitRestClients() { RestClient = new RestClient(RootUrl + "api/"); RestClient.AddDefaultHeader("Authentication", ApiKey); RestClient.AddDefaultHeader("X-Api-Key", ApiKey); Blacklist = new ClientBase <BlacklistResource>(RestClient, ApiKey); Commands = new CommandClient(RestClient, ApiKey); DownloadClients = new DownloadClientClient(RestClient, ApiKey); Episodes = new EpisodeClient(RestClient, ApiKey); History = new ClientBase <HistoryResource>(RestClient, ApiKey); Indexers = new IndexerClient(RestClient, ApiKey); NamingConfig = new ClientBase <NamingConfigResource>(RestClient, ApiKey, "config/naming"); Notifications = new NotificationClient(RestClient, ApiKey); Releases = new ReleaseClient(RestClient, ApiKey); RootFolders = new ClientBase <RootFolderResource>(RestClient, ApiKey); Series = new SeriesClient(RestClient, ApiKey); Tags = new ClientBase <TagResource>(RestClient, ApiKey); }
public async Task ReturnsNullWhenIncorrectSeriesId() { var series = await SeriesClient.GetById(int.MaxValue); Assert.Null(series); }
public async Task ReturnsNullWhenIncorrectAuthor() { var series = await SeriesClient.GetListByAuthorId(int.MaxValue); Assert.Null(series); }
protected virtual void InitRestClients() { RestClient = new RestClient(RootUrl + "api/"); RestClient.AddDefaultHeader("Authentication", ApiKey); RestClient.AddDefaultHeader("X-Api-Key", ApiKey); Blacklist = new ClientBase<BlacklistResource>(RestClient, ApiKey); Commands = new CommandClient(RestClient, ApiKey); DownloadClients = new DownloadClientClient(RestClient, ApiKey); Episodes = new EpisodeClient(RestClient, ApiKey); History = new ClientBase<HistoryResource>(RestClient, ApiKey); HostConfig = new ClientBase<HostConfigResource>(RestClient, ApiKey, "config/host"); Indexers = new IndexerClient(RestClient, ApiKey); NamingConfig = new ClientBase<NamingConfigResource>(RestClient, ApiKey, "config/naming"); Notifications = new NotificationClient(RestClient, ApiKey); Profiles = new ClientBase<ProfileResource>(RestClient, ApiKey); Releases = new ReleaseClient(RestClient, ApiKey); RootFolders = new ClientBase<RootFolderResource>(RestClient, ApiKey); Series = new SeriesClient(RestClient, ApiKey); Tags = new ClientBase<TagResource>(RestClient, ApiKey); WantedMissing = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/missing"); WantedCutoffUnmet = new ClientBase<EpisodeResource>(RestClient, ApiKey, "wanted/cutoff"); }
private void InitRestClients() { RestClient = new RestClient(RootUrl + "api/"); RestClient.AddDefaultHeader("Authentication", _runner.ApiKey); RestClient.AddDefaultHeader("X-Api-Key", _runner.ApiKey); Series = new SeriesClient(RestClient, _runner.ApiKey); Releases = new ReleaseClient(RestClient, _runner.ApiKey); RootFolders = new ClientBase<RootFolderResource>(RestClient, _runner.ApiKey); Commands = new ClientBase<CommandResource>(RestClient, _runner.ApiKey); History = new ClientBase<HistoryResource>(RestClient, _runner.ApiKey); Indexers = new IndexerClient(RestClient, _runner.ApiKey); Episodes = new EpisodeClient(RestClient, _runner.ApiKey); NamingConfig = new ClientBase<NamingConfigResource>(RestClient, _runner.ApiKey, "config/naming"); Notifications = new NotificationClient(RestClient, _runner.ApiKey); }