Exemplo n.º 1
0
        public void GetLatestReleases_ReturnsCorrectAlbums()
        {
            // Arrange
            var context = this.ServiceProvider.GetRequiredService <WmipDbContext>();
            var album1  = new Album {
                Id = 1, Name = "Abm1", ReleaseDate = DateTime.UtcNow.AddDays(-1), ApprovalStatus = ApprovalStatus.Approved, ReleaseStage = ReleaseStage.Released
            };
            var album2 = new Album {
                Id = 2, Name = "Abm2", ReleaseDate = DateTime.UtcNow.AddDays(-2), ApprovalStatus = ApprovalStatus.Approved, ReleaseStage = ReleaseStage.Released
            };
            var album3 = new Album {
                Id = 3, Name = "Abm3", ReleaseDate = DateTime.UtcNow.AddDays(+1), ApprovalStatus = ApprovalStatus.Approved, ReleaseStage = ReleaseStage.Released
            };

            context.Albums.AddRange(album1, album2, album3);
            context.SaveChanges();
            var albumsService = new AlbumsService(context);

            // Act
            var results = albumsService.GetLatestReleases(1);

            //Assert
            Assert.Equal(1, results.First().Id);
        }