public void GetByHash_Fail(Type booruType, string?hash = null) { var booru = BooruHelper.CreateBooru <IBooruPostByHash>(booruType); hash ??= new string('0', 32); Assert.ThrowsAsync <InvalidPostHashException>(() => booru.GetPostAsync(hash)); }
public async Task GetByHash_Success(Type booruType, string hash, int expectedId) { var booru = BooruHelper.CreateBooru <IBooruPostByHash>(booruType); var post = await booru.GetPostAsync(hash); Assert.AreEqual(expectedId, post.ID); }
public async Task GetById_Success(Type booruType, int id) { var booru = BooruHelper.CreateBooru <IBooruPostById>(booruType); var post = await booru.GetPostAsync(id); Assert.AreEqual(id, post.ID); }
public async Task GetByName_Success(Type booruType, string name, TagKind kind) { var booru = BooruHelper.CreateBooru <IBooruTagByName>(booruType); var tag = await booru.GetTagAsync(name); Assert.AreEqual(name, tag.Name); Assert.AreEqual(kind, tag.Kind); }
public void GetByHash_Cancellation(Type booruType, string hash) { var booru = BooruHelper.CreateBooru <IBooruPostByHash>(booruType); using var tokenSource = new CancellationTokenSource(); tokenSource.CancelAfter(BooruHelper.TaskCancellationDelay); Assert.ThrowsAsync <TaskCanceledException>(() => booru.GetPostAsync(hash, tokenSource.Token)); }
public void GetByName_Cancellation(Type booruType, string name = _normalTag) { // IMPORTANT: create raw instance here to not mess with other tests. // See TagsCache.cs. var booru = BooruHelper.CreateBooru <IBooruTagByName>(booruType); using var tokenSource = new CancellationTokenSource(); tokenSource.CancelAfter(BooruHelper.TaskCancellationDelay); Assert.ThrowsAsync <TaskCanceledException>(() => booru.GetTagAsync(name, tokenSource.Token)); }
public void GetById_Cancellation(Type booruType, int id) { // IMPORTANT: create raw instance here to not mess with other tests. // See PostCache.cs. var booru = BooruHelper.CreateBooru <IBooruPostById>(booruType); using var tokenSource = new CancellationTokenSource(); tokenSource.CancelAfter(BooruHelper.TaskCancellationDelay); Assert.ThrowsAsync <TaskCanceledException>(() => booru.GetPostAsync(id, tokenSource.Token)); }
public void GetByName_Fail(Type booruType, string name = _invalidTag) { var booru = BooruHelper.CreateBooru <IBooruTagByName>(booruType); Assert.ThrowsAsync <InvalidTagNameException>(() => booru.GetTagAsync(name)); }
public void GetById_Fail(Type booruType) { var booru = BooruHelper.CreateBooru <IBooruPostById>(booruType); Assert.ThrowsAsync <InvalidPostIdException>(() => booru.GetPostAsync(0)); }