Пример #1
0
        public async Task HandleSuccessResponse()
        {
            //Arrange
            const string tagName = "disco";
            const string tagUri  = "http://www.last.fm/tag/disco";

            var command     = new GetInfoCommand(MAuth.Object, tagName);
            var expectedTag = new LastTag(tagName, tagUri)
            {
                Reach      = 34671,
                Count      = 172224,
                Streamable = true
            };


            //Act
            var response     = CreateResponseMessage(Encoding.UTF8.GetString(TagApiResponses.GetInfoSuccess));
            var lastResponse = await command.HandleResponse(response);

            var tag = lastResponse.Content;

            //Assert
            Assert.IsTrue(lastResponse.Success);
            Assert.AreEqual(expectedTag.Reach, tag.Reach);
            Assert.AreEqual(expectedTag.Name, tag.Name);
            Assert.AreEqual(expectedTag.Count, tag.Count);
            Assert.AreEqual(expectedTag.Streamable, tag.Streamable);
        }
Пример #2
0
        public async Task HandleSuccessResponse()
        {
            //Arrange
            const string tagName = "disco";
            const string tagUri = "http://www.last.fm/tag/disco";

            var command = new GetInfoCommand(MAuth.Object, tagName);
            var expectedTag=new LastTag(tagName,tagUri)
            {
                Reach = 34671,
                Count = 172224,
                Streamable = true
            };


            //Act
            var response = CreateResponseMessage(Encoding.UTF8.GetString(TagApiResponses.GetInfoSuccess));
            var lastResponse = await command.HandleResponse(response);
            var tag = lastResponse.Content;

            //Assert
            Assert.IsTrue(lastResponse.Success);
            Assert.AreEqual(expectedTag.Reach,tag.Reach);
            Assert.AreEqual(expectedTag.Name, tag.Name);
            Assert.AreEqual(expectedTag.Count, tag.Count);
            Assert.AreEqual(expectedTag.Streamable, tag.Streamable);
        }
Пример #3
0
        public async Task HandleSuccessResponse()
        {
            var expectedAlbum = new LastAlbum
            {
                ArtistName     = "Madonna",
                ListenerCount  = 509271,
                PlayCount      = 7341494,
                Mbid           = "ddb3168d-66a9-4b2d-af02-05278da8a23d",
                Url            = new Uri("http://www.last.fm/music/Madonna/Ray+of+Light", UriKind.Absolute),
                Name           = "Ray of Light",
                ReleaseDateUtc = new DateTime(2005, 09, 13, 0, 0, 0),
                Id             = "1934",
                Images         = new LastImageSet(
                    "http://userserve-ak.last.fm/serve/34s/37498173.png",
                    "http://userserve-ak.last.fm/serve/64s/37498173.png",
                    "http://userserve-ak.last.fm/serve/174s/37498173.png",
                    "http://userserve-ak.last.fm/serve/300x300/37498173.png",
                    "http://userserve-ak.last.fm/serve/_/37498173/Ray+of+Light.png"),
                TopTags = new List <LastTag>
                {
                    new LastTag("albums i own", "http://www.last.fm/tag/albums%20i%20own"),
                    new LastTag("pop", "http://www.last.fm/tag/pop"),
                    new LastTag("electronic", "http://www.last.fm/tag/electronic"),
                    new LastTag("dance", "http://www.last.fm/tag/dance"),
                    new LastTag("madonna", "http://www.last.fm/tag/madonna")
                }
            };

            var file     = GetFileContents("AlbumApi.AlbumGetInfoSuccess.json");
            var response = CreateResponseMessage(file);
            //var response = CreateResponseMessage(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetInfoSuccess));
            var parsed = await _command.HandleResponse(response);

            Assert.IsTrue(parsed.Success);

            var actual = parsed.Content;

            Assert.IsTrue(actual.Tracks.Count() == 13);
            actual.Tracks = null;

            var expectedJson = JsonConvert.SerializeObject(expectedAlbum, Formatting.Indented);
            var actualJson   = JsonConvert.SerializeObject(parsed.Content, Formatting.Indented);

            Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
        }
Пример #4
0
        public async Task HandleErrorResponse()
        {
            var command = new GetInfoCommand(MAuth.Object, "errorTag");

            var response = CreateResponseMessage(Encoding.UTF8.GetString(TagApiResponses.GetInfoError));

            var parsed = await command.HandleResponse(response);

            Assert.IsFalse(parsed.Success);
            Assert.IsTrue(parsed.Status == LastResponseStatus.MissingParameters);
        }
Пример #5
0
        public async Task HandleErrorResponse()
        {
            var command = new GetInfoCommand(MAuth.Object, "errorTag");

            var response = CreateResponseMessage(Encoding.UTF8.GetString(TagApiResponses.GetInfoError));

            var parsed = await command.HandleResponse(response);

            Assert.IsFalse(parsed.Success);
            Assert.IsTrue(parsed.Status == LastResponseStatus.MissingParameters);
        }
Пример #6
0
        public async Task HandleSuccessResponse()
        {
            var expectedArtist = new LastArtist()
            {
                Name      = "Frightened Rabbit",
                Mbid      = "dc21d171-7204-4759-9fd0-77d031aeb40c",
                Url       = new Uri("http://www.last.fm/music/Frightened+Rabbit"),
                MainImage = new LastImageSet("http://userserve-ak.last.fm/serve/34/50340089.jpg",
                                             "http://userserve-ak.last.fm/serve/64/50340089.jpg",
                                             "http://userserve-ak.last.fm/serve/126/50340089.jpg",
                                             "http://userserve-ak.last.fm/serve/252/50340089.jpg",
                                             "http://userserve-ak.last.fm/serve/_/50340089/Frightened+Rabbit+frabbit.jpg"),
                // todo streamable
                OnTour  = false,
                Similar = new List <LastArtist>
                {
                    new LastArtist
                    {
                        Name      = "Admiral Fallow",
                        Url       = new Uri("http://www.last.fm/music/Admiral+Fallow"),
                        MainImage = new LastImageSet("http://userserve-ak.last.fm/serve/34/48454975.jpg",
                                                     "http://userserve-ak.last.fm/serve/64/48454975.jpg",
                                                     "http://userserve-ak.last.fm/serve/126/48454975.jpg",
                                                     "http://userserve-ak.last.fm/serve/252/48454975.jpg",
                                                     "http://userserve-ak.last.fm/serve/500/48454975/Admiral+Fallow+l_1185fb2755064ccfbab2871ecec8.jpg")
                    },
                    new LastArtist
                    {
                        Name      = "The Twilight Sad",
                        Url       = new Uri("http://www.last.fm/music/The+Twilight+Sad"),
                        MainImage = new LastImageSet("http://userserve-ak.last.fm/serve/34/18201771.jpg",
                                                     "http://userserve-ak.last.fm/serve/64/18201771.jpg",
                                                     "http://userserve-ak.last.fm/serve/126/18201771.jpg",
                                                     "http://userserve-ak.last.fm/serve/252/18201771.jpg",
                                                     "http://userserve-ak.last.fm/serve/500/18201771/The+Twilight+Sad+hi+how+are+you.jpg"),
                    },
                    new LastArtist
                    {
                        Name      = "Owl John",
                        Url       = new Uri("http://www.last.fm/music/Owl+John"),
                        MainImage = new LastImageSet("http://userserve-ak.last.fm/serve/34/101981791.png",
                                                     "http://userserve-ak.last.fm/serve/64/101981791.png",
                                                     "http://userserve-ak.last.fm/serve/126/101981791.png",
                                                     "http://userserve-ak.last.fm/serve/252/101981791.png",
                                                     "http://userserve-ak.last.fm/serve/500/101981791/Owl+John+owl.png"),
                    },
                    new LastArtist
                    {
                        Name      = "We Were Promised Jetpacks",
                        Url       = new Uri("http://www.last.fm/music/We+Were+Promised+Jetpacks"),
                        MainImage = new LastImageSet("http://userserve-ak.last.fm/serve/34/53527397.jpg",
                                                     "http://userserve-ak.last.fm/serve/64/53527397.jpg",
                                                     "http://userserve-ak.last.fm/serve/126/53527397.jpg",
                                                     "http://userserve-ak.last.fm/serve/252/53527397.jpg",
                                                     "http://userserve-ak.last.fm/serve/_/53527397/We+Were+Promised+Jetpacks+wwpj.jpg"),
                    },
                    new LastArtist
                    {
                        Name      = "Meursault",
                        Url       = new Uri("http://www.last.fm/music/Meursault"),
                        MainImage = new LastImageSet("http://userserve-ak.last.fm/serve/34/41921789.jpg",
                                                     "http://userserve-ak.last.fm/serve/64/41921789.jpg",
                                                     "http://userserve-ak.last.fm/serve/126/41921789.jpg",
                                                     "http://userserve-ak.last.fm/serve/252/41921789.jpg",
                                                     "http://userserve-ak.last.fm/serve/_/41921789/Meursault+lovely+fuckwits.jpg"),
                    }
                },
                Tags = new List <LastTag>
                {
                    new LastTag("indie", "http://www.last.fm/tag/indie"),
                    new LastTag("scottish", "http://www.last.fm/tag/scottish"),
                    new LastTag("indie rock", "http://www.last.fm/tag/indie%20rock"),
                    new LastTag("folk", "http://www.last.fm/tag/folk"),
                    new LastTag("folk rock", "http://www.last.fm/tag/folk%20rock"),
                },
                Bio = new LastWiki
                {
                    Content    = "Frightened Rabbit are an <a href=\"http://www.last.fm/tag/indie%20rock\" class=\"bbcode_tag\" rel=\"tag\">indie rock</a> band which formed in 2003 in Glasgow, Scotland. The band currently consists of Scott Hutchison (vocals, guitar), Billy Kennedy (guitar, keyboards), Grant Hutchison (drums, vocals), Andy Monaghan (guitar, keyboards) and Gordon Skene (guitar, keyboards). The band has released four albums: &quot;Sing the Greys&quot; (2006), &quot;The Midnight Organ Fight&quot; (2008), &quot;The Winter of Mixed Drinks&quot; (2010) and &quot;Pedestrian Verse&quot; (2013).  \n\n        <a href=\"http://www.last.fm/music/Frightened+Rabbit\">Read more about Frightened Rabbit on Last.fm</a>.\n    \n    \nUser-contributed text is available under the Creative Commons By-SA License and may also be available under the GNU FDL.",
                    Summary    = "Frightened Rabbit are an <a href=\"http://www.last.fm/tag/indie%20rock\" class=\"bbcode_tag\" rel=\"tag\">indie rock</a> band which formed in 2003 in Glasgow, Scotland. The band currently consists of Scott Hutchison (vocals, guitar), Billy Kennedy (guitar, keyboards), Grant Hutchison (drums, vocals), Andy Monaghan (guitar, keyboards) and Gordon Skene (guitar, keyboards). The band has released four albums: &quot;Sing the Greys&quot; (2006), &quot;The Midnight Organ Fight&quot; (2008), &quot;The Winter of Mixed Drinks&quot; (2010) and &quot;Pedestrian Verse&quot; (2013).  \n\n        <a href=\"http://www.last.fm/music/Frightened+Rabbit\">Read more about Frightened Rabbit on Last.fm</a>.",
                    Published  = new DateTimeOffset(2013, 2, 6, 0, 4, 40, TimeSpan.Zero),
                    YearFormed = 2003
                },
                Stats = new LastStats
                {
                    Listeners = 513447,
                    Plays     = 0
                }
            };

            var file     = GetFileContents("ArtistApi.ArtistGetInfoSuccess.json");
            var response = CreateResponseMessage(file);
            //var response = CreateResponseMessage(Encoding.UTF8.GetString(ArtistApiResponses.ArtistGetInfoSucess));
            var parsed = await _command.HandleResponse(response);

            Assert.IsTrue(parsed.Success);

            var expectedJson = expectedArtist.TestSerialise();
            var actualJson   = parsed.Content.TestSerialise();

            Assert.AreEqual(expectedJson, actualJson, expectedJson.DifferencesTo(actualJson));
        }