예제 #1
0
        public void Create_IncreasesCountAndAddsItem()
        {
            // Arrange
            var context       = this.ServiceProvider.GetRequiredService <WmipDbContext>();
            var albumsService = new AlbumsService(context);
            var creationInfo  = new CreateAlbumDto()
            {
                AlbumCoverLink  = "newlink",
                Genre           = "newgenre",
                Name            = "newname",
                ReleaseDate     = DateTime.Now.AddDays(1),
                ReleaseStage    = ReleaseStage.Announced,
                SpotifyLink     = "newSLink",
                SelectedSongIds = new int[] { 1, 2, 3, 4, 5, 6, 7 }
            };

            // Act
            albumsService.Create(creationInfo);

            //Assert
            Assert.Single(context.Albums);
            Assert.Equal(creationInfo.Name, context.Albums.First().Name);
            Assert.Equal(creationInfo.AlbumCoverLink, context.Albums.First().AlbumCoverLink);
            Assert.Equal(creationInfo.Genre, context.Albums.First().Genre);
            Assert.Equal(creationInfo.ReleaseDate, context.Albums.First().ReleaseDate);
            Assert.Equal(creationInfo.ReleaseStage, context.Albums.First().ReleaseStage);
            Assert.Equal(creationInfo.SpotifyLink, context.Albums.First().SpotifyLink);
            Assert.Equal(creationInfo.SelectedSongIds, context.Albums.First().AlbumsSongs.Select(s => s.SongId));
        }