public void ValidEditSave() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act Genre moba = new Genre { GenreId = 1, Name = "Moba", Description = "Angry team simulator." }; VideoGame game1 = new VideoGame { VideoGameId = 1, Name = "CS:GO", Price = 20, Developer = "UK", Publisher = "Steam", Description = "FPS Game", Genre = moba }; ViewResult result = controller.Edit(1) as ViewResult; // Assert Assert.AreEqual("Edit", result.ViewName); }
public void CreateInvalid() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; Genre fps = new Genre { Name = "FPS", Description = "First-person shooter." }; Genre moba = new Genre { GenreId = 100, Name = "Moba", Description = "Angry team simulator." }; VideoGame game1 = new VideoGame { VideoGameId = 3, Name = "CS : GO", Price = 20, Developer = "UK", Publisher = "Steam", Description = "FPS Game", Genre = fps }; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act ViewResult result = controller.Create(game1) as ViewResult; // Assert Assert.AreEqual("Create", result.ViewName); }
public void get_all_video_Games() { VideoGamesController vgc = new VideoGamesController(); var videoGames = vgc.GetVideoGames(); Assert.IsNotNull(videoGames); }
public void get_video_game_by_Id() { VideoGamesController vgc = new VideoGamesController(); var videoGame = vgc.GetVideoGame(1); Assert.IsNotNull(videoGame); }
public void NotTestCase() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = false; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act //controller.Index(); // Assert Assert.AreEqual(false, controller.testCase); }
public void IndexTest() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //Act ViewResult result = controller.Index() as ViewResult; //Assert Assert.AreEqual(result.ViewName, "Index"); }
public void Dispose() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act controller.Dispose(); // Assert Assert.IsTrue(true); }
public void DeleteConfirmedValidId() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act System.Web.Mvc.RedirectToRouteResult actual = (System.Web.Mvc.RedirectToRouteResult)controller.DeleteConfirmed(1); // Assert Assert.AreEqual("VideoGames", actual.RouteValues["action"]); }
public void CreateView() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act ViewResult result = controller.Create() as ViewResult; // Assert Assert.AreEqual("Create", result.ViewName); }
public void DetailValidId() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act ViewResult result = controller.Details(3) as ViewResult; // Assert Assert.IsNotNull(result.ViewName); }
public void InvalidEdit() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act ViewResult result = controller.Edit(200) as ViewResult; // Assert Assert.AreEqual("Error", result.ViewName); }
public void DetailNull() { //Arrange FakeNullVideoGame fake = new FakeNullVideoGame(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act ViewResult result = controller.Details(3) as ViewResult; // Assert //Assert.AreEqual("", result.ViewName); Assert.AreEqual("Error", result.ViewName); }
public void AddReview() { //Arrange FakeVideoGamesBL fake = new FakeVideoGamesBL(); VideoGamesController controller = new VideoGamesController(fake); controller.testCase = true; //var result = (VideoGame)((ViewResult)controller.Details(1)).Model; // Act string result = controller.AddReview(1, 1, "test", 5, "test"); // Assert Assert.AreEqual("Success", result); }
public void update_video_game() { var newName = "Unit Test"; VideoGame videoGame; VideoGamesController vgc = new VideoGamesController(); VideoGameRepository repo = new VideoGameRepository(); videoGame = repo.GetVideoGameByID(1); //Update Name videoGame.Name = newName; //save vgc.PostVideoGame(videoGame); //requery from DB videoGame = repo.GetVideoGameByID(1); //check Assert.AreEqual(videoGame.Name, newName); }