inflatablefriends / lastfm

Portable .Net library for Last.fm
Other
100 stars 62 forks source link

Bug in TestHelpers.cs AssertValues? #137

Closed klinge closed 5 years ago

klinge commented 5 years ago

The AssertValues-method compares a number of values from the page response to expected values. Among the assertions being tested are these:

Assert.IsTrue(pageResponse.TotalItems == totalItems, testMessage("totalitems", totalItems));
...          
Assert.IsTrue(pageResponse.Content.Count == totalItems, testMessage("content length", totalItems));

So both pageResponse.TotalItems and pageResponse.Content.Count are compared to the input parameter totalItems.

From my understanding the pageResponse.TotalItems is the same as the "total" attribute in the Lastfm response. The pageResponse.Content.Count should be similar to Lastfm responses "perPage" attribute.

An example from Last.fm. Calling the Artist.GetTopAlbums like this: /?method=artist.gettopalbums&artist=steely+dan&api_key={{apikey}}&format=json

Results in page attributes as follows:

        "@attr": {
            "artist": "Steely Dan",
            "page": "1",
            "perPage": "50",
            "totalPages": "338",
            "total": "16875"
        }

I think it would be more correct to change the assert on pageResponse.Content.Count to: Assert.IsTrue(pageResponse.Content.Count == pageSize, testMessage("content length", pageSize));

Or am I missing something here? :)

klinge commented 5 years ago

This seems to be working fine in all tests so closing this for now.