public void AddSongToUser_InvalidModelState_ReturnBadRequest()
        {
            _inventoryController.ModelState.AddModelError("Error", "Bad");

            var result = _inventoryController.AddSongToUser(new AddRemoveUserSongViewModel());

            Assert.IsInstanceOfType(result, typeof(BadRequestErrorMessageResult));
        }
Esempio n. 2
0
        public void AddSongToUser_AddRemoveUserSongViewModel_AddsSongToUser()
        {
            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 viewModel = new AddRemoveUserSongViewModel
            {
                SongId = song.SongId,
                UserId = user.UserId
            };

            _inventoryController.AddSongToUser(viewModel);

            var       updatedUser = _context.Users.Find(user.Id);
            const int expected    = 1;

            Assert.AreEqual(expected, updatedUser.UserSongs.Count);
        }