示例#1
0
        public void ReturnStringErrorWhenGetArticlesAsJsonCalledAndNoApiKey()
        {
            string _apiKey = null;
            var    _client = Substitute.For <IRestClient>();
            var    caller  = new ApiCaller(_client, _apiKey);

            var response = caller.GetArticlesAsJson();

            var arguments = (RestRequest)_client.ReceivedCalls().First().GetArguments().First();

            var xApiKey = arguments.Parameters.FirstOrDefault(param => param.Name == "X-Api-Key");

            xApiKey.Value.ShouldBeNull();
        }
示例#2
0
        public void ReturnAStringWhenGetArticlesAsJsonCalled()
        {
            var _client   = Substitute.For <IRestClient>();
            var _response = Substitute.For <IRestResponse>();

            _response.Content.Returns("cat");
            _client.Execute(Arg.Any <IRestRequest>()).Returns(_response);
            string _apiKey = null;

            var caller = new ApiCaller(_client, _apiKey);

            var response = caller.GetArticlesAsJson();

            response.ShouldNotBeNullOrEmpty();
        }