Beispiel #1
0
        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));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
            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);
            }
Beispiel #5
0
        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));
        }
Beispiel #6
0
            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));
            }
Beispiel #7
0
        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));
        }
Beispiel #8
0
            public void GetByName_Fail(Type booruType, string name = _invalidTag)
            {
                var booru = BooruHelper.CreateBooru <IBooruTagByName>(booruType);

                Assert.ThrowsAsync <InvalidTagNameException>(() => booru.GetTagAsync(name));
            }
Beispiel #9
0
        public void GetById_Fail(Type booruType)
        {
            var booru = BooruHelper.CreateBooru <IBooruPostById>(booruType);

            Assert.ThrowsAsync <InvalidPostIdException>(() => booru.GetPostAsync(0));
        }