コード例 #1
0
        public void ChannelSearchTest()
        {
            var request = new ChannelSearchRequest
            {
                Key        = this.ApiKey,
                Query      = "google",
                MaxResults = 1
            };

            var response = GoogleSearch.VideoSearch.Channels.Query(request);

            Assert.IsNotNull(response);
            Assert.AreEqual(response.Status, Status.Ok);
        }
コード例 #2
0
        public void ChannelSearchWhenAsyncAndCancelledTest()
        {
            var request = new ChannelSearchRequest
            {
                Key   = this.ApiKey,
                Query = "google"
            };

            var cancellationTokenSource = new CancellationTokenSource();
            var task = GoogleSearch.VideoSearch.Channels.QueryAsync(request, cancellationTokenSource.Token);

            cancellationTokenSource.Cancel();

            var exception = Assert.Throws <OperationCanceledException>(() => task.Wait(cancellationTokenSource.Token));

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "The operation was canceled.");
        }