示例#1
0
        public async Task ReturnArtistCountOfDb_Correctly()
        {
            //Arrange
            var options = Utils.GetOptions(nameof(ReturnArtistCountOfDb_Correctly));
            var plMock  = new Mock <IPlaylistService>();

            var artists = new List <Artist>()
            {
                new Artist()
                {
                    Id         = 1,
                    ArtistName = "The weeknd"
                },
                new Artist()
                {
                    Id         = 2,
                    ArtistName = "Bad Wolfs"
                }
            };

            //Act
            using (var arrangeContext = new RidePalDbContext(options))
            {
                await arrangeContext.Artists.AddRangeAsync(artists);

                await arrangeContext.SaveChangesAsync();
            }

            //Assert
            using (var assertContext = new RidePalDbContext(options))
            {
                var sut    = new StatisticsService(assertContext, plMock.Object);
                int result = await sut.ArtistCount();

                Assert.IsTrue(result == 2);
            }
        }