コード例 #1
0
        public async Task AddSongToFavoritesTest()
        {
            const string lyrics = "lorem ips subsciat boom bap da ting go skrrrrra ka ka pa pa pa";

            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "InHarmonyTestLogicDB")
                          .Options;

            using (var context = new ApplicationDbContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                Repository         _repository        = new Repository(context, _logger);
                BusinessLogicClass businessLogicClass = new BusinessLogicClass(_repository, _mapperClass, _logger);
                // create a user
                var user = new User
                {
                    UserName  = "******",
                    Password  = "******",
                    FirstName = "Johnny",
                    LastName  = "Test",
                    Email     = "*****@*****.**"
                };
                // create a song
                var song = new Song
                {
                    ArtistName    = "Bad Posture",
                    Genre         = "Pop Punk",
                    Title         = "Yellow",
                    Duration      = TimeSpan.MaxValue,
                    NumberOfPlays = int.MaxValue,
                    Lyrics        = lyrics,
                    isOriginal    = true
                };

                // add the song to the user's favorite list
                await businessLogicClass.AddSongToFavorites(song.Id, user.Id);

                Assert.NotNull(_repository.favoriteLists);
            }
        }
コード例 #2
0
 public async Task addSongToFavorites(int songid, int userId)
 {
     await _businessLogicClass.AddSongToFavorites(songid, userId);
 }