public async Task GetAlbumByIdAsyncTest_ValidId_CorrectData() { // Arrange var albumRepoMock = new Mock <IAlbumRepository>(); albumRepoMock.Setup(mock => mock.GetAlbumByIdAsync(1)) .ReturnsAsync(new AlbumDataDto { Id = 1, Name = "Test", CoverArt = "", }) .Verifiable(); var albumCollection = new AlbumCollection(albumRepoMock.Object, _dependencyMapper); // Act var album = await albumCollection.GetAlbumByIdAsync(1); // Assert albumRepoMock.Verify(); Assert.AreEqual(1, album.Id); Assert.AreEqual("Test", album.Name); Assert.AreEqual("", album.CoverArt); }
public async Task GetAlbumByIdAsyncTest_InvalidId_Null() { // Arrange var albumRepoMock = new Mock <IAlbumRepository>(); albumRepoMock.Setup(mock => mock.GetAlbumByIdAsync(1)) .ReturnsAsync(null as AlbumDataDto) .Verifiable(); var albumCollection = new AlbumCollection(albumRepoMock.Object, _dependencyMapper); // Act var album = await albumCollection.GetAlbumByIdAsync(1); // Assert albumRepoMock.Verify(); Assert.AreEqual(null, album); }