public void AddOnePlaylist() { var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict); mockPlaylist.Setup(res => res.Get(playlistList[0].Id)).Returns(playlistList[0]); PlaylistController controller = new PlaylistController(mockPlaylist.Object); var result = controller.Add(playlistList[0]); var okResult = result as OkObjectResult; Assert.AreEqual(new ObjectResult("").ToString(), controller.Add(playlistList[0]).ToString()); }
public void AddPlaylistError() { playlistList[0].Name = ""; var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict); mockPlaylist.Setup(r => r.Add(playlistList[0])).Throws(new FieldEnteredNotCorrect("")); PlaylistController controller = new PlaylistController(mockPlaylist.Object); var result = controller.Add(playlistList[0]); Assert.AreEqual(new UnprocessableEntityObjectResult("").ToString(), result.ToString()); }
public void DeletePlaylistIdNegative() { var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict); var controller = new PlaylistController(mockPlaylist.Object); controller.Add(playlistList[0]); var result = controller.DeletePlaylist(-2); Assert.AreEqual(new NotFoundObjectResult("").ToString(), result.ToString()); }
public void DeletePlaylistOk() { var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict); mockPlaylist.Setup(t => t.Get(1)).Returns(playlistList[0]); mockPlaylist.Setup(t => t.Delete(playlistList[0])); var controller = new PlaylistController(mockPlaylist.Object); controller.Add(playlistList[0]); var result = controller.DeletePlaylist(1); Assert.AreEqual(new OkObjectResult("").ToString(), result.ToString()); }
public void AddPlaylistErrorCategoryUnique() { List <PlaylistCategory> list = new List <PlaylistCategory>(); PlaylistCategory play = new PlaylistCategory { IdCategory = 1 }; PlaylistCategory play2 = new PlaylistCategory { IdCategory = 1 }; list.Add(play); list.Add(play2); playlistList[0].PlaylistCategory = list; var mockPlaylist = new Mock <IPlaylistLogic>(MockBehavior.Strict); mockPlaylist.Setup(r => r.Add(playlistList[0])).Throws(new EntityAlreadyExist("")); PlaylistController controller = new PlaylistController(mockPlaylist.Object); var result = controller.Add(playlistList[0]); Assert.AreEqual(new UnprocessableEntityObjectResult("").ToString(), result.ToString()); }