Пример #1
0
        public async Task TestStream()
        {
            // Check that the user has an Xbox Music Pass subscription
            UserProfileResponse userProfileResponse = await AuthenticatedClient.GetUserProfileAsync(Namespace.music).Log();

            // Beware: HasSubscription is bool?. You want != true instead of == false
            if (userProfileResponse.HasSubscription != true)
            {
                Assert.Inconclusive("The user doesn't have an Xbox Music Pass subscription. Cannot stream from catalog.");
            }

            // Get popular tracks in the user's country
            ContentResponse browseResults = await AuthenticatedClient.BrowseAsync(Namespace.music, ContentSource.Catalog, ItemType.Tracks).Log();

            Assert.IsNotNull(browseResults, "The browse response should not be null");
            AssertPaginatedListIsValid(browseResults.Tracks, 25, 100);

            // Stream the first streamable track
            Track          track          = browseResults.Tracks.Items.First(t => t.Rights.Contains("Stream"));
            StreamResponse streamResponse = await AuthenticatedClient.StreamAsync(track.Id, ClientInstanceId).Log();

            Assert.IsNotNull(streamResponse, "The stream URL response should not be null");
            Assert.IsNotNull(streamResponse.Url, "The stream URL should not be null");
            Assert.IsNotNull(streamResponse.ContentType, "The stream content type should not be null");
            Assert.IsNotNull(streamResponse.ExpiresOn, "The stream expiry date should not be null");
        }