コード例 #1
0
        public void ExecuteRequest_PocoTypeCouldNotBeMapped_RealExceptionShouldBeThrow()
        {
            var client          = new RestClient(SharpBucketV2.BITBUCKET_URL);
            var requestExecutor = new FakeRequestExecutor();

            var exception = Should.Throw <Exception>(
                () => requestExecutor.ExecuteRequest <IteratorBasedPage <BadSearchCodeSearchResult> >(
                    "teams/Atlassian/search/code",
                    Method.GET,
                    null,
                    client,
                    new Dictionary <string, object>
            {
                { "search_query", "string" },
            }),
                "Using a bad POCO should produce an Exception, but not a BitbucketException since it's not an issue detected by BitBucket, but an issue in our code.");

            exception.Message.ShouldBe("No parameterless constructor defined for type 'SharpBucket.V2.Pocos.SearchContentMatch[]'.");
        }
コード例 #2
0
        public void ExecuteRequest_BadRequest_BitbucketExceptionShouldBeThrow()
        {
            var client          = new RestClient(SharpBucketV2.BITBUCKET_URL);
            var requestExecutor = new FakeRequestExecutor();

            var exception = Should.Throw <BitbucketException>(
                () => requestExecutor.ExecuteRequest <IteratorBasedPage <SearchCodeSearchResult> >(
                    "teams/Atlassian/search/code",
                    Method.GET,
                    null,
                    client,
                    new Dictionary <string, object>
            {
                { "bad_search_query", "string" },
            }),
                "Using a bad query should produce a BitBucketException, since it's Bitbucket that detect the error and say it to us.'");

            exception.Message.ShouldBe("{\"type\": \"error\", \"error\": {\"message\": \"You must provide a search query\"}}");
        }