Пример #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();
        }
Пример #2
0
        public async Task xtreamJsonReader_GetPanelInfo(string url)
        {
            var panelJsonData = await GetXtreamPanel(url);

            var mockHttpClientFactory = new Mock <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.None);

            panel.Categories.ShouldNotBeNull();
            panel.User_info.ShouldNotBeNull();
            panel.Server_info.ShouldNotBeNull();
            panel.Available_Channels.ShouldNotBeNull();
        }