Exemplo n.º 1
0
        public async Task XtreamClient_OK(string url, CancellationToken cancellationToken = default)
        {
            var panelJsonData = await GetXtreamPanel(url);

            var mockHttpClientFactory = new Mock <Xtream.Client.IHttpClientFactory>();

            MockHttpClient(mockHttpClientFactory, panelJsonData);

            var xtreamJsonReader = new XtreamJsonReader(mockHttpClientFactory.Object);
            var connectionInfo   = new XtBasicConnectionFactory("http://server.tes", "", "").Create();
            var panel            = await xtreamJsonReader.GetFromApi <XtreamPanel>(connectionInfo, XtreamApiEnum.Panel_Api, cancellationToken);

            var mockXtreamClient = new Mock <IXtreamClient>();

            mockXtreamClient.Setup(x => x.GetPanelAsync(It.IsAny <ConnectionInfo>(), cancellationToken)).ReturnsAsync(panel);
            mockXtreamClient.Setup(x => x.GetLiveStreamsAsync(It.IsAny <ConnectionInfo>(), cancellationToken)).ReturnsAsync(panel.Available_Channels);
            mockXtreamClient.Setup(x => x.GetLiveCategoriesAsync(It.IsAny <ConnectionInfo>(), cancellationToken)).ReturnsAsync(panel.Categories.Live);

            var ds = new XtreamPlaylistDataSource
            {
                Authentication = new BasicAuthentication("user", "pwd"),
                Server         = UriAddress.For("http://test.tv")
            };

            var medias = await new XtreamDataSourceReader(ds, mockXtreamClient.Object).GetMediasAsync();

            medias.ShouldNotBeNull();
        }
Exemplo n.º 2
0
 public static ConnectionInfo GetConnection(this XtreamPlaylistDataSource xtreamPlaylistDataSource)
 {
     if (xtreamPlaylistDataSource.Server == null || string.IsNullOrEmpty(xtreamPlaylistDataSource.Server.Url))
     {
         throw new XtreamConnectionInfoException("Xtream connection info error (Server can't be null)");
     }
     return(new ConnectionInfo(xtreamPlaylistDataSource.Server.Url, xtreamPlaylistDataSource.Authentication?.User, xtreamPlaylistDataSource.Authentication?.Password));
 }
Exemplo n.º 3
0
 public XtreamDataSourceReader(XtreamPlaylistDataSource dataSource, IXtreamClient xtreamClient)
 {
     _dataSource   = dataSource;
     _xtreamClient = xtreamClient;
 }