Ejemplo n.º 1
0
        public async Task GetArtistByIdAsyncTest_ValidId_CorrectData()
        {
            // Arrange
            var artistRepoMock = new Mock <IArtistRepository>();

            artistRepoMock.Setup(mock => mock.GetArtistByIdAsync(1))
            .ReturnsAsync(new ArtistDataDto
            {
                Id      = 1,
                Name    = "Test",
                Picture = "",
            })
            .Verifiable();

            var artistCollection = new ArtistCollection(artistRepoMock.Object, _dependencyMapper);

            // Act
            var artist = await artistCollection.GetArtistByIdAsync(1);

            // Assert
            artistRepoMock.Verify();
            Assert.AreEqual(1, artist.Id);
            Assert.AreEqual("Test", artist.Name);
            Assert.AreEqual("", artist.Picture);
        }
Ejemplo n.º 2
0
        public async Task GetArtistByIdAsyncTest_InvalidId_Null()
        {
            // Arrange
            var artistRepoMock = new Mock <IArtistRepository>();

            artistRepoMock.Setup(mock => mock.GetArtistByIdAsync(1))
            .ReturnsAsync(null as ArtistDataDto)
            .Verifiable();

            var artistCollection = new ArtistCollection(artistRepoMock.Object, _dependencyMapper);

            // Act
            var artist = await artistCollection.GetArtistByIdAsync(1);

            // Assert
            artistRepoMock.Verify();
            Assert.AreEqual(null, artist);
        }