public TFLHost ( IRoadStatusService roadStatusService, IApplicationLifetime applicationLifetime, IConfiguration configuration ) { _roadStatusService = roadStatusService; _applicationLifetime = applicationLifetime; _configuration = configuration; }
public async Task TestWithInValidUrlRaiseException(string baseUrl) { // Arrange httpClient.BaseAddress = new Uri(baseUrl); roadStatusService = new RoadStatusService(loggerMock.Object, httpClient, optionMock.Object); // Act HttpRequestException ex = await Task.Run(() => Assert.ThrowsAsync <HttpRequestException>(async() => await roadStatusService.GetRoadStatusDetail("a2"))); // Assert Assert.AreEqual("Error: Expected Error occured.", ex.Message); Assert.IsTrue(ex.InnerException.Message.Contains("No such host is known")); }
public async Task TestWithInValidRoadIdReturnNonZeroExitCode(string baseUrl, string roadId) { // Arrange httpClient.BaseAddress = new Uri(baseUrl); roadStatusService = new RoadStatusService(loggerMock.Object, httpClient, optionMock.Object); // Act var result = await roadStatusService.GetRoadStatusDetail(roadId); // Assert Assert.IsNotNull(result); Assert.IsNull(result.RoadStatus); Assert.AreEqual(1, result.StatusCode); }
public async Task TestWithValidUrlReturnCorrectResult(string baseUrl) { // Arrange httpClient.BaseAddress = new Uri(baseUrl); roadStatusService = new RoadStatusService(loggerMock.Object, httpClient, optionMock.Object); // Act var result = await roadStatusService.GetRoadStatusDetail("a2"); // Assert Assert.IsNotNull(result); Assert.AreEqual(0, result.StatusCode); Assert.AreEqual(1, result.RoadStatus.Count()); }
public async Task TestWithInValidAppKeyAndIdRaiseException(string baseUrl, string roadId, string appkey, string appId) { // Arrange httpClient.BaseAddress = new Uri(baseUrl); roadStatusService = new RoadStatusService(loggerMock.Object, httpClient, optionMock.Object); optionMock.Setup(x => x.Value).Returns(new RemoteServiceSettings { ApiId = appId, ApiKey = appkey, BaseUrl = baseUrl }); // Act HttpRequestException ex = await Task.Run(() => Assert.ThrowsAsync <HttpRequestException>(async() => await roadStatusService.GetRoadStatusDetail("a2"))); // Assert Assert.AreEqual("Error: Expected Error occured.", ex.Message); Assert.IsTrue(ex.InnerException.Message.Contains("Unexpected character encountered")); }
public ProcessRoadService(IRoadStatusService roadStatusService) { _roadStatusService = roadStatusService; }
public App(IRoadStatusService roadStatusService) { this._roadStatusService = roadStatusService; }