public void WebClient_CallUrlWithInvalidUrlScenario005_ArgumentExceptionThrown()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            const string invalidUrl = "http://tempuri.org..";

            Assert.That(() => webRequestService.CallUrl(invalidUrl, "{ name: \"Dave\" }"), Throws.Exception.TypeOf<ArgumentException>().With.Property("ParamName").EqualTo("url"));
        }
        public async Task WebClient_CallUrlWithValidArgs_NoExceptionThrown()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            await webRequestService.CallUrl(ServiceUrl, "{ name: \"Dave\" }");

            //No need to explicitly assert anything, we just want no exception
        }
        public void WebClient_CallUrlWithInvalidDataScenario003_ArgumentExceptionThrown()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            const string invalidData = "{ name: \"Dave\", \"Age\" : 48, \"Sex\" : male }";

            Assert.That(() => webRequestService.CallUrl(ValidUrl, invalidData), Throws.Exception.TypeOf<ArgumentException>().With.Property("ParamName").EqualTo("data"));
        }
        public async Task WebClient_CallUrlWithValidArgsAndNullData_GetRequestIsMade()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            var url = ServiceUrl;

            await webRequestService.CallUrl(url, null);

            A.CallTo(() => _fakeHttpService.GetRequest(url)).MustHaveHappened();
        }
        public async Task WebClient_CallUrlWithValidUrlScenario002_ArgumentExceptionNotThrown()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            const string validUrl = "https://tempuri.org";

            await webRequestService.CallUrl(validUrl, "{ name: \"Dave\" }");

            //No need to assert, just checking no exception is thrown
        }
        public async Task WebClient_CallUrlWithValidDataScenario003_ArgumentExceptionNotThrown()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            const string validData = "{ name: \"Dave\", \"Age\" : 48, \"Sex\" : \"male\" }";

            await webRequestService.CallUrl(ValidUrl, validData);

            //No need to assert, just checking no exception is thrown
        }
        public async Task WebClient_CallUrlWithValidArgsAndRealData_PostRequestIsMade()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            var url = ServiceUrl;

            var data = "{ name: \"Dave\" }";

            await webRequestService.CallUrl(url, data);

            A.CallTo(() => _fakeHttpService.PostRequest(url, A<Dictionary<string,string>>.Ignored)).MustHaveHappened();
        }
        public void WebClient_CallUrlWithInvalidData_ArgumentExceptionThrown()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            Assert.That(() => webRequestService.CallUrl(ServiceUrl, "bad json"), Throws.Exception.TypeOf<ArgumentException>().With.Property("ParamName").EqualTo("data"));
        }
        public void WebClient_CallUrlWithInvalidUrl_ArgumentExceptionThrown()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            Assert.That(() => webRequestService.CallUrl("I am an invalid url", "{ name: \"Dave\" }"), Throws.Exception.TypeOf<ArgumentException>().With.Property("ParamName").EqualTo("url"));
        }
        public void WebClient_CreateWebRequestService_InstanceIsOfCorrectType()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            Assert.IsInstanceOf(typeof(WebRequestService), webRequestService);
        }
        public void WebClient_CreateWebRequestService_InstanceIsNotNull()
        {
            var webRequestService = new WebRequestService(_fakeHttpService);

            Assert.IsNotNull(webRequestService);
        }