Exemplo n.º 1
0
        public void ToDTOOfPlayHistoryItem_ConvertedToDTO()
        {
            var now = DateTime.UtcNow;
            var sut = new PlayHistoryItem
            {
                Context = new Context
                {
                    ExternalUrls = new Dictionary <string, string>(),
                    Href         = "SomeHREF",
                    Type         = "SomeType",
                    Uri          = "SomeURI"
                },
                Id       = "Unneeded value.",
                PlayedAt = now,
                Track    = new SimpleTrack
                {
                    Artists          = new List <SimpleArtist>(),
                    AvailableMarkets = new List <string>(),
                    DiscNumber       = 1,
                    DurationMs       = 3600,
                    Explicit         = true,
                    ExternalUrls     = new Dictionary <string, string>(),
                    Href             = "AnotherHref",
                    Id          = "12345678",
                    IsPlayable  = true,
                    LinkedFrom  = new LinkedTrack(),
                    Name        = "My favourite song",
                    PreviewUrl  = "https://google.com",
                    TrackNumber = 5,
                    Type        = ItemType.Track,
                    Uri         = "AnotherURI"
                }
            };

            var convertedPlayHistoryItem = new DTO.PlayHistoryItem
            {
                Context = new DTO.Context
                {
                    ExternalUrls = new Dictionary <string, string>(),
                    Href         = "SomeHREF",
                    Type         = "SomeType",
                    Uri          = "SomeURI"
                },
                PlayedAt = now,
                Track    = new DTO.SimpleTrack
                {
                    Artists          = new List <DTO.SimpleArtist>(),
                    AvailableMarkets = new List <string>(),
                    DiscNumber       = 1,
                    DurationMs       = 3600,
                    Explicit         = true,
                    ExternalUrls     = new Dictionary <string, string>(),
                    Href             = "AnotherHref",
                    Id          = "12345678",
                    IsPlayable  = true,
                    LinkedFrom  = new DTO.LinkedTrack(),
                    Name        = "My favourite song",
                    PreviewUrl  = "https://google.com",
                    TrackNumber = 5,
                    Type        = ItemType.Track,
                    Uri         = "AnotherURI"
                }
            };

            var convertedObject = sut.ToDTO();

            convertedObject.Should().NotBeNull();
            convertedObject.Should().BeOfType <DTO.PlayHistoryItem>();
            convertedObject.Should().BeEquivalentTo(convertedPlayHistoryItem);
        }
Exemplo n.º 2
0
        public void GivenAListOfSpotifyListeningHistory(Table table)
        {
            var fakeListeningHistory = new List <FakeResponseServer.Models.Spotify.PlayHistoryItem>();
            var count = 0;

            foreach (var row in table.Rows)
            {
                var listeningHistoryItem = new PlayHistoryItem
                {
                    PlayedAt = DateTime.ParseExact(row["Time of listening"], "dd'/'MM'/'yyyy HH:mm:ss", null),
                    Track    = new SimpleTrack
                    {
                        Artists          = new List <SimpleArtist>(),
                        AvailableMarkets = new List <string>(),
                        DiscNumber       = 1,
                        DurationMs       = 3500,
                        Explicit         = false,
                        ExternalUrls     = new Dictionary <string, string>(),
                        Href             = "https://api.spotify.com/v1/albums/SomeHref",
                        Id         = count.ToString() + "SPOTIFY",
                        IsPlayable = true,
                        LinkedFrom = new LinkedTrack
                        {
                            ExternalUrls = new Dictionary <string, string>(),
                            Href         = "https://api.spotify.com/v1/albums/SomeOtherHref",
                            Id           = count.ToString() + "SPOTIFY",
                            Type         = "Track",
                            Uri          = "spotify:album:SomeOtherURI"
                        },
                        Name        = row["Song name"],
                        PreviewUrl  = "https://p.scdn.co/mp3-preview/SomeRef",
                        TrackNumber = 1,
                        Type        = ItemType.Track,
                        Uri         = "SomeURI",
                    },
                    Context = new Context
                    {
                        ExternalUrls = new Dictionary <string, string>(),
                        Href         = "https://api.spotify.com/v1/albums/SomeURI",
                        Type         = "Album",
                        Uri          = "spotify:album:SomeURI" + count.ToString() + "SPOTIFY"
                    }
                };
                var fakeHistoryItem = new FakeResponseServer.Models.Spotify.PlayHistoryItem
                {
                    Id       = count.ToString(),
                    PlayedAt = DateTime.ParseExact(row["Time of listening"], "dd'/'MM'/'yyyy HH:mm:ss", null),
                    Track    = new FakeResponseServer.Models.Spotify.SimpleTrack
                    {
                        Artists          = new List <FakeResponseServer.Models.Spotify.SimpleArtist>(),
                        AvailableMarkets = new List <string>(),
                        DiscNumber       = 1,
                        DurationMs       = 3500,
                        Explicit         = false,
                        ExternalUrls     = new Dictionary <string, string>(),
                        Href             = "https://api.spotify.com/v1/albums/SomeHref",
                        Id         = count.ToString() + "SPOTIFY",
                        IsPlayable = true,
                        LinkedFrom = new FakeResponseServer.Models.Spotify.LinkedTrack
                        {
                            ExternalUrls = new Dictionary <string, string>(),
                            Href         = "https://api.spotify.com/v1/albums/SomeOtherHref",
                            Id           = count.ToString() + "SPOTIFY",
                            Type         = "Track",
                            Uri          = "spotify:album:SomeOtherURI"
                        },
                        Name        = row["Song name"],
                        PreviewUrl  = "https://p.scdn.co/mp3-preview/SomeRef",
                        TrackNumber = 1,
                        Type        = FakeResponseServer.Models.Spotify.ItemType.Track,
                        Uri         = "SomeURI",
                    },
                    Context = new FakeResponseServer.Models.Spotify.Context
                    {
                        ExternalUrls = new Dictionary <string, string>(),
                        Href         = "https://api.spotify.com/v1/albums/SomeURI",
                        Type         = "Album",
                        Uri          = "spotify:album:SomeURI" + count.ToString() + "SPOTIFY"
                    }
                };

                spotifyListeningHistory.Add(listeningHistoryItem);
                fakeListeningHistory.Add(fakeHistoryItem);
                count++;
            }
            dataSource.AddSpotifyListeningHistory(fakeListeningHistory);
        }