public async Task GetServicePointAsync_ServiceReturnsUnauthorizedStatus_ReturnsNull() { _messageHandler.SendAsyncReturns(new HttpResponseMessage(HttpStatusCode.Unauthorized)); ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, Factory.GetString(7)); Assert.Null(result); }
public async Task GetServicePointAsync_ServiceReturnsNull_ReturnsNull() { _messageHandler.SendAsyncReturns(null); ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, Factory.GetString(7)); Assert.Null(result); }
public async Task GetServicePointAsync_ServiceReturnsValidJson_ReturnsServicePointInfo() { _messageHandler.SendAsyncReturns(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(GetValidServiceResultJson(singleResult: true)) }); ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, Factory.GetString(7)); Assert.IsType <ServicePointInformation>(result); }
public async Task GetServicePointAsync_ServiceReturnsValidJson_CacheServicePointInfo() { _messageHandler.SendAsyncReturns(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(GetValidServiceResultJson(singleResult: true)) }); ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, Factory.GetString(7)); _cacheHelperMock.Verify(m => m.Insert(It.IsAny <string>(), result, It.IsAny <TimeSpan>())); }
public async Task GetServicePointAsync_ParseResultFails_ReturnsNull() { _messageHandler.SendAsyncReturns(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{ 'Some': 'random', 'unparasable': 'json' }") }); ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, Factory.GetString(4)); Assert.Null(result); }
public async Task GetServicePointAsync_ServiceReturnsValidJson_ReturnsServiceWithCorrectCoordinates() { _messageHandler.SendAsyncReturns(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(GetValidServiceResultJson(singleResult: true)) }); ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, Factory.GetString(7)); Assert.Equal(10.754335161831872F, result.Easting); Assert.Equal(59.91169773310983F, result.Northing); Assert.Equal("EPSG:4326", result.CoordinateId); }
public async Task GetServicePointAsync_ItemFoundInCache_ReturnsCachedResult() { string pickupPointId = Factory.GetString(7); var cachedResult = new ServicePointInformation { Id = pickupPointId }; _cacheHelperMock.Setup(m => m.Get <ServicePointInformation>(It.IsAny <string>())).Returns(cachedResult); ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, pickupPointId); Assert.Same(cachedResult, result); }
public async Task GetServicePointAsync_ItemFoundInCache_DoesNotCallService() { string pickupPointId = Factory.GetString(7); var cachedResult = new ServicePointInformation { Id = pickupPointId }; _cacheHelperMock.Setup(m => m.Get <ServicePointInformation>(It.IsAny <string>())).Returns(cachedResult); await _service.GetServicePointAsync(_clientInfo, pickupPointId); Assert.Equal(0, _messageHandler.CallCount()); }
public void Ctor_OpeningHours_IsNotNull() { var model = new ServicePointInformation(); Assert.NotNull(model.OpeningHours); }
public async Task GetServicePointAsync_PickupPointIsNullOrEmpty_ReturnsNull(string pickupPointId) { ServicePointInformation result = await _service.GetServicePointAsync(_clientInfo, pickupPointId); Assert.Null(result); }