Beispiel #1
0
        public void AddSongToUser_UserSong_AddsUserSongToDatabase()
        {
            var user = new User {
                Id = Guid.NewGuid(), UserId = Guid.NewGuid()
            };
            var song = new Song {
                Id = Guid.NewGuid(), SongId = Guid.NewGuid(), Album = new Album {
                    Id = Guid.NewGuid()
                }
            };

            _context.Users.Add(user);
            _context.Songs.Add(song);
            _context.SaveChanges();

            var userSong = new UserSong
            {
                Id         = Guid.NewGuid(),
                UserSongId = Guid.NewGuid(),
                SongId     = song.SongId,
                User       = new User {
                    UserId = user.UserId
                }
            };

            _inventoryService.AddSongToUser(userSong);

            var result = _context.UserSongs.First();

            Assert.AreEqual(result.Id, userSong.Id);
        }
        public void AddSongToUser_UserSong_CallsUserRepoGet()
        {
            var userSong = new UserSong
            {
                SongId = Guid.NewGuid(),
                User   = new User {
                    UserId = Guid.NewGuid()
                }
            };

            _inventoryService.AddSongToUser(userSong);

            _userRepository.Verify(x => x.Get(It.IsAny <Guid>()), Times.AtLeastOnce);
        }