Beispiel #1
0
        public async Task GetAlbumsAsyncTest()
        {
            // Arrange
            var result = new AlbumDataDto
            {
                Id       = 1,
                ArtistId = 1,
                Name     = "Test",
                CoverArt = ""
            };

            var albumCollectionMock = new Mock <IAlbumCollection>();

            albumCollectionMock
            .Setup(mock => mock.GetAlbumsByArtistIdAsync(1))
            .ReturnsAsync(new[] { new Album(result, null, null, null) })
            .Verifiable();

            var artist = new Artist(new ArtistDataDto
            {
                Id      = 1,
                Name    = "Test",
                Picture = "",
            }, albumCollectionMock.Object, null);

            // Act
            var albums = (await artist.GetAlbumsAsync()).ToArray();

            // Assert
            albumCollectionMock.Verify();
            Assert.AreEqual(1, albums.Length);
            Assert.AreEqual(1, albums[0].Id);
        }
Beispiel #2
0
        public async Task GetAlbumAsyncTest()
        {
            // Arrange
            var result = new AlbumDataDto
            {
                Id       = 1,
                Name     = "",
                ArtistId = 0,
                CoverArt = "",
            };

            var albumCollectionMock = new Mock <IAlbumCollection>();

            albumCollectionMock
            .Setup(mock => mock.GetAlbumByIdAsync(1))
            .ReturnsAsync(new Album(result, null, null, null))
            .Verifiable();

            var song = new Song(new SongDataDto
            {
                Id       = 1,
                AlbumId  = 1,
                Name     = "",
                FileName = "",
                Duration = 0,
            }, null, albumCollectionMock.Object, null);

            // Act
            var album = await song.GetAlbumAsync();

            // Assert
            albumCollectionMock.Verify();
            Assert.AreEqual(1, song.Id);
        }
Beispiel #3
0
        public Album(AlbumDataDto dto, IAlbumRepository albumRepository, IArtistCollection artistCollection, ISongCollection songCollection)
        {
            Id       = dto.Id;
            Name     = dto.Name;
            CoverArt = dto.CoverArt;

            _artistId = dto.ArtistId;

            _albumRepository  = albumRepository;
            _artistCollection = artistCollection;
            _songCollection   = songCollection;
        }