예제 #1
0
        public void UnitTestHelloWorldConsoleAppRunNormalDataNullData()
        {
            var    mockParameters   = new Mock <List <Parameter> >();
            var    mockRestResponse = new Mock <IRestResponse <HWData> >();
            HWData data             = null;

            this.restRequestMock.Setup(m => m.Parameters).Returns(mockParameters.Object);
            this.restClientMock.Setup(m => m.Execute <HWData>(It.IsAny <IRestRequest>())).Returns(mockRestResponse.Object);
            mockRestResponse.Setup(m => m.Data).Returns(data);

            var resp = this.helloWorldService.GetData();

            Assert.IsNull(resp);
        }
예제 #2
0
        public HWData GetData()
        {
            HWData hwData     = null;
            var    baseUrl    = ConfigurationManager.AppSettings.Get("HWApiUrl");
            var    urlBaseurl = new Uri(baseUrl);

            this.restClient.BaseUrl   = urlBaseurl;
            this.restRequest.Resource = "HW";
            this.restRequest.Method   = Method.GET;
            this.restRequest.Parameters.Clear();

            var hwDataResponse = this.restClient.Execute <HWData>(this.restRequest);

            if (hwDataResponse != null)
            {
                if (hwDataResponse.Data != null)
                {
                    hwData = hwDataResponse.Data;
                }
            }
            return(hwData);
        }