예제 #1
0
        public void Test_Playlists_GetList()
        {
            const string expectedUri = @"https://api.soundcloud.com/playlists?limit=10&q=search&representation=compact&linked_partitioning=1&client_id=myClientId";

            var playlists = new PagedResult <Playlist>();

            playlists.collection = new List <Playlist> {
                new Playlist(), new Playlist()
            };

            var response = new ApiResponse <PagedResult <Playlist> >(HttpStatusCode.OK, "OK");

            response.Data = playlists;

            var requestMock = new Mock <ISoundCloudApiGateway>(MockBehavior.Strict);

            requestMock.Setup(x => x.InvokeGetRequest <PagedResult <Playlist> >(It.Is <Uri>(y => y.ToString() == expectedUri))).Returns(response);

            var playlistEndpoint = new Playlists(requestMock.Object);

            playlistEndpoint.Credentials.ClientId = ClientId;

            var builder = new PlaylistQueryBuilder("search");

            builder.Representation = RepresentationMode.Compact;

            var result = playlistEndpoint.Get(builder).ToList();

            Assert.That(result, Is.EqualTo(playlists.collection));
        }
예제 #2
0
        public void Test_Playlists_Get()
        {
            const string expectedUri = @"https://api.soundcloud.com/playlists/130208739?client_id=myClientId";

            var playlist = new Playlist();

            var response = new ApiResponse <Playlist>(HttpStatusCode.OK, "OK");

            response.Data = playlist;

            var requestMock = new Mock <ISoundCloudApiGateway>(MockBehavior.Strict);

            requestMock.Setup(x => x.InvokeGetRequest <Playlist>(It.Is <Uri>(y => y.ToString() == expectedUri))).Returns(response);

            var playlistEndpoint = new Playlists(requestMock.Object);

            playlistEndpoint.Credentials.ClientId = ClientId;

            var result = playlistEndpoint.Get(PlaylistId);

            Assert.That(result, Is.EqualTo(playlist));
        }