public async Task DeleteAlbumByNameShouldAuthorizeAlbumDeletion() { _sut.ControllerContext = new ControllerContext { HttpContext = new DefaultHttpContext { User = new ClaimsPrincipal(new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, "User") }, "AuthenticationType")) } }; _albumViewerContext.Albums.Add(new Album { Id = 1, Title = "Delete" }); _albumViewerContext.Albums.Add(new Album { Id = 2, Title = "Keep" }); _albumViewerContext.Albums.Add(new Album { Id = 3, Title = "Delete" }); _albumViewerContext.SaveChanges(); await _sut.DeleteAlbumByName("Delete"); await _albumRepository.Received(1).DeleteAlbum(1); await _albumRepository.DidNotReceive().DeleteAlbum(2); await _albumRepository.Received(1).DeleteAlbum(3); }
public async Task GetAllAlbumsShouldReturnOneAlbumWhen15AlbumsPerPage(int generatedAlbums, int page) { for (var i = 0; i < generatedAlbums; i++) { _albumViewerContext.Albums.Add(new Album { Title = $"Album{i}" }); } _albumViewerContext.SaveChanges(); var sut = new AlbumRepository(_albumViewerContext); var albums = await sut.GetAllAlbums(page); Assert.AreEqual(albums.Count, 1); }