Exemple #1
0
        public async Task Can_Get_Line_Information_If_Response_Cannot_Be_Cached()
        {
            // Arrange
            var builder = CreateBuilder()
                          .Requests()
                          .ForPath("Line/Mode/dlr%2Coverground%2Ctflrail%2Ctube")
                          .Responds()
                          .WithJsonContent(new[] { new { id = "district", name = "District" } });

            _interceptor.Register(builder);

            using var httpClient   = _interceptor.CreateHttpClient();
            httpClient.BaseAddress = _options.BaseUri;

            ITflClient client = CreateClient(httpClient);
            var        target = new TflService(client, _cache, _options);

            // Act
            ICollection <LineInfo> actual1 = await target.GetLinesAsync();

            ICollection <LineInfo> actual2 = await target.GetLinesAsync();

            // Assert
            Assert.NotNull(actual1);
            Assert.Equal(1, actual1.Count);

            var item = actual1.First();

            Assert.Equal("district", item.Id);
            Assert.Equal("District", item.Name);

            Assert.NotSame(actual1, actual2);
        }
Exemple #2
0
        public async Task Can_Get_Stop_Points_If_Response_Cannot_Be_Cached()
        {
            // Arrange
            var builder = CreateBuilder()
                          .Requests()
                          .ForPath("Line/victoria/StopPoints")
                          .Responds()
                          .WithJsonContent(new[] { new { id = "940GZZLUGPK", commonName = "Green Park Underground Station", lat = 51.506947, lon = -0.142787 } });

            _interceptor.Register(builder);

            using var httpClient   = _interceptor.CreateHttpClient();
            httpClient.BaseAddress = _options.BaseUri;

            ITflClient client = CreateClient(httpClient);
            var        target = new TflService(client, _cache, _options);

            // Act
            ICollection <StopPoint> actual1 = await target.GetStopPointsByLineAsync("victoria");

            ICollection <StopPoint> actual2 = await target.GetStopPointsByLineAsync("victoria");

            // Assert
            Assert.NotNull(actual1);
            Assert.Equal(1, actual1.Count);

            var item = actual1.First();

            Assert.Equal("940GZZLUGPK", item.Id);
            Assert.Equal("Green Park Underground Station", item.Name);
            Assert.Equal(51.506947, item.Latitude);
            Assert.Equal(-0.142787, item.Longitude);

            Assert.NotSame(actual1, actual2);
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommuteIntent"/> class.
 /// </summary>
 /// <param name="skillClient">The skill client to use.</param>
 /// <param name="tflClient">The TfL API client to use.</param>
 /// <param name="contextAccessor">The AWS Lambda context accessor to use.</param>
 /// <param name="config">The skill configuration to use.</param>
 /// <param name="logger">The logger to use.</param>
 public CommuteIntent(
     ISkillClient skillClient,
     ITflClient tflClient,
     SkillConfiguration config,
     ILogger <CommuteIntent> logger)
 {
     Config      = config;
     Logger      = logger;
     SkillClient = skillClient;
     TflClient   = tflClient;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TflService"/> class.
 /// </summary>
 /// <param name="client">The <see cref="ITflClient"/> to use.</param>
 /// <param name="cache">The <see cref="IMemoryCache"/> to use.</param>
 /// <param name="options">The <see cref="TflOptions"/> to use.</param>
 public TflService(ITflClient client, IMemoryCache cache, TflOptions options)
 {
     _client  = client;
     _cache   = cache;
     _options = options;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="StatusIntent"/> class.
 /// </summary>
 /// <param name="tflClient">The TfL API client to use.</param>
 /// <param name="config">The skill configuration to use.</param>
 public StatusIntent(ITflClient tflClient, SkillConfiguration config)
 {
     Config    = config;
     TflClient = tflClient;
 }
Exemple #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisruptionIntent"/> class.
 /// </summary>
 /// <param name="tflClient">The TfL API client to use.</param>
 /// <param name="config">The skill configuration to use.</param>
 public DisruptionIntent(ITflClient tflClient, SkillConfiguration config)
 {
     Config    = config;
     TflClient = tflClient;
 }
 public RoadService(ITflClient data)
 {
     this.data = data;
 }