public async void ServiceWhitelistFilter_EmptyWhitelistReturnsAllResults() { const string postcode = "SO302UN"; string whitelistUrl = string.Format(_localServiceIdWhiteListUrl, postcode); _restClient.Setup(r => r.ExecuteTaskAsync <CCGDetailsModel>(It.Is <RestRequest>(req => req.Resource.Equals(whitelistUrl)))).Returns(() => StartedTask((IRestResponse <CCGDetailsModel>) new RestResponse <CCGDetailsModel>() { StatusCode = HttpStatusCode.OK, ResponseStatus = ResponseStatus.Completed, Data = new CCGDetailsModel { ServiceIdWhitelist = new ServiceListModel { } } })); var jObj = (JObject)JsonConvert.DeserializeObject(CheckCapacitySummaryResults); var results = jObj["CheckCapacitySummaryResult"].ToObject <List <Models.Models.Business.DosService> >(); //Act var sut = new ServiceWhitelistFilter(_restClient.Object, _mockConfiguration.Object); var result = await sut.Filter(results, postcode); Assert.AreEqual(3, result.Count); Assert.AreEqual(1419419101, result[0].Id); Assert.AreEqual(1419419102, result[1].Id); Assert.AreEqual(1419419103, result[2].Id); }
public async void ServiceWhitelistFilter_CCGServiceServerError() { const string postcode = "SO302UN"; string whitelistUrl = string.Format(_localServiceIdWhiteListUrl, postcode); _restClient.Setup(r => r.ExecuteTaskAsync <CCGDetailsModel>(It.Is <RestRequest>(req => req.Resource.Equals(whitelistUrl)))).Returns(() => StartedTask((IRestResponse <CCGDetailsModel>) new RestResponse <CCGDetailsModel>() { StatusCode = HttpStatusCode.InternalServerError, ResponseStatus = ResponseStatus.Completed, Data = new CCGDetailsModel { } })); var jObj = (JObject)JsonConvert.DeserializeObject(CheckCapacitySummaryResults); var results = jObj["CheckCapacitySummaryResult"].ToObject <List <Models.Models.Business.DosService> >(); //Act try { var sut = new ServiceWhitelistFilter(_restClient.Object, _mockConfiguration.Object); var result = await sut.Filter(results, postcode); Assert.Fail(); } catch (HttpException) { Assert.Pass(); } }