public void PlanHoliday()
        {
            ApiResponseService Api = new ApiResponseService();
            string             responseCityForcast = Api.getResponse(ConfigurationManager.AppSettings["cityname"], ConfigurationManager.AppSettings["noofdays"]);

            Console.WriteLine(responseCityForcast.ToString());
            Assert.IsTrue(responseCityForcast.Contains(ConfigurationManager.AppSettings["cityname"]));
        }
Esempio n. 2
0
        public void TestInitialise()
        {
            _dateTime = new Mock <IDateTimeWrapper>();
            _client   = new Mock <IHttpClientWrapper>();
            _contentServiceFactory = new Mock <IResponseContentServiceFactory>();

            _service = new ApiResponseService(_dateTime.Object,
                                              _client.Object,
                                              _contentServiceFactory.Object);

            _contentService      = new Mock <IReadResponseContentService>();
            _errorContentService = new Mock <IReadResponseContentService>();
            _response            = new Mock <HttpResponseMessage>();

            _first             = 11.May(2020).At(12, 15, 00);
            _responseTime      = new TimeSpan(00, 05, 00);
            _second            = _first.Add(_responseTime);
            _responseIsSuccess = true;
            _content           = new object();
            _request           = new HttpRequestMessage();
            _statusCode        = HttpStatusCode.OK;
            var dateTimeQueue = new Queue <DateTime>();

            dateTimeQueue.Enqueue(_first);
            dateTimeQueue.Enqueue(_second);

            _contentServiceFactory.Setup(s => s.GetService(typeof(TestType)))
            .Returns(() => _contentService?.Object).Verifiable();
            _contentServiceFactory.Setup(s => s.GetService(typeof(object)))
            .Returns(() => _errorContentService?.Object).Verifiable();
            _contentService.Setup(s => s.ReadContent(It.IsAny <HttpResponseMessage>()))
            .Returns(() => Task.FromResult(_content)).Verifiable();
            _errorContentService.Setup(s => s.ReadContent(It.IsAny <HttpResponseMessage>()))
            .Returns(() => Task.FromResult(_content)).Verifiable();
            _response.Object.StatusCode = _statusCode;
            _dateTime.Setup(d => d.Now).Returns(() => dateTimeQueue.Dequeue());
            _client.Setup(c => c.SendAsync(_request))
            .Returns(() => Task.FromResult(_response.Object)).Verifiable();
        }
Esempio n. 3
0
        protected override void BeginProcessing()
        {
            base.BeginProcessing();

            if (_clientWrapper == null)
            {
                _clientWrapper = new HttpClientWrapper();
            }

            var apiResponseService = new ApiResponseService(new DateTimeWrapper(),
                                                            _clientWrapper,
                                                            new ResponseContentServiceFactory());
            var checkParametersService   = new CheckRequiredParametersService();
            var responseRecorder         = new ResponseRecorderService();
            var addContentServiceFactory = new AddContentServiceFactory(new AddJsonContentToRequestService());
            var addPathParamsService     = new AddPathParamsService();
            var addQueryParamsService    = new AddQueryParamsService();
            var addHeaderParamsService   = new AddHeaderParamsService();
            var uriService           = new UriGenerateService(addPathParamsService, addQueryParamsService);
            var createMessageService = new CreateMessageService(uriService,
                                                                addContentServiceFactory,
                                                                addHeaderParamsService);

            if (_invocationService == null)
            {
                _invocationService = new InvokeOpenApiEndpointService(apiResponseService,
                                                                      checkParametersService,
                                                                      createMessageService,
                                                                      responseRecorder);
            }

            if (_objectCreator == null)
            {
                _objectCreator = new ObjectCreator(new EnumFromStringService());
            }
        }