Example #1
0
 public TFLHost
 (
     IRoadStatusService roadStatusService,
     IApplicationLifetime applicationLifetime,
     IConfiguration configuration
 )
 {
     _roadStatusService   = roadStatusService;
     _applicationLifetime = applicationLifetime;
     _configuration       = configuration;
 }
Example #2
0
        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"));
        }
Example #3
0
        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);
        }
Example #4
0
        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());
        }
Example #5
0
        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"));
        }
Example #6
0
 public ProcessRoadService(IRoadStatusService roadStatusService)
 {
     _roadStatusService = roadStatusService;
 }
Example #7
0
 public App(IRoadStatusService roadStatusService)
 {
     this._roadStatusService = roadStatusService;
 }