Exemplo n.º 1
0
        public async Task CreateAlbumAsyncTest()
        {
            // Arrange
            var albumRepoMock = new Mock <IAlbumRepository>();

            albumRepoMock.Setup(mock => mock.CreateAlbumAsync(It.Is((NewAlbumDataDto dataDto) => (
                                                                        dataDto.Name == "Test" &&
                                                                        dataDto.ArtistId == 1
                                                                        ))))
            .ReturnsAsync(new AlbumDataDto
            {
                Id       = 1,
                ArtistId = 1,
                Name     = "Test",
                CoverArt = "",
            })
            .Verifiable();

            var albumCollection = new AlbumCollection(albumRepoMock.Object, _dependencyMapper);

            // Act
            var album = await albumCollection.CreateAlbumAsync(1, "Test");

            // Assert
            albumRepoMock.Verify();
            Assert.AreEqual(1, album.Id);
            Assert.AreEqual("Test", album.Name);
        }