Ejemplo n.º 1
0
        public async Task ShouldUpdatePlaylistWithAllParams()
        {
            // Arrange
            const string playlistId = "40C5k2GWBlficlUyQKmR0S";
            var          request    = new ChangePlaylistDetailsRequest()
            {
                Name          = "Test Playlist",
                Description   = "Test Playlist Description",
                Collaborative = true,
                Public        = true
            };

            this.MockHttp
            .ExpectSpotifyRequest(HttpMethod.Put, $"playlists/{playlistId}")
            .WithExactQueryString(string.Empty)
            .WithJsonContent(j =>
                             j.EnumerateObject().Count() == 4 &&
                             j.TryGetProperty("name", out var name) && name.GetString() == request.Name &&
                             j.TryGetProperty("description", out var description) && description.GetString() == request.Description &&
                             j.TryGetProperty("collaborative", out var collaborative) && collaborative.GetBoolean() == request.Collaborative &&
                             j.TryGetProperty("public", out var @public) && @public.GetBoolean() == request.Public)
            .Respond(HttpStatusCode.OK);

            // Act
            await this.Client.Playlists(playlistId).ChangeDetailsAsync(request);

            // Assert
            this.MockHttp.VerifyNoOutstandingExpectation();
        }
Ejemplo n.º 2
0
        public async Task ShouldUpdatePlaylist()
        {
            // Arrange
            const string playlistId = "40C5k2GWBlficlUyQKmR0S";
            var          request    = new ChangePlaylistDetailsRequest();

            this.MockHttp
            .ExpectSpotifyRequest(HttpMethod.Put, $"playlists/{playlistId}")
            .WithExactQueryString(string.Empty)
            .WithJsonContent(j => !j.EnumerateObject().Any())
            .Respond(HttpStatusCode.OK);

            // Act
            await this.Client.Playlists(playlistId).ChangeDetailsAsync(request);

            // Assert
            this.MockHttp.VerifyNoOutstandingExpectation();
        }
Ejemplo n.º 3
0
 public Task ChangeDetailsAsync(ChangePlaylistDetailsRequest changePlaylistDetailsRequest, CancellationToken cancellationToken)
 => this.SendBodyAsync(HttpMethod.Put, changePlaylistDetailsRequest, cancellationToken);