public void GetShouldGetTheaterByName() { //Arrange var dbcontext = new BroadwayBuilderContext(); var theater = new Theater("createTheater", "Regal", "theater st", "LA", "CA", "US", "323323"); var service = new TheaterService(dbcontext); service.CreateTheater(theater); dbcontext.SaveChanges(); var controller = new TheaterController(); //Act var actionResult = controller.GetTheaterByName(theater.TheaterName); var response = actionResult as NegotiatedContentResult <Theater>; var content = response.Content; //Assert Assert.IsNotNull(response); Assert.IsNotNull(response.Content); Assert.AreEqual(theater.TheaterName, content.TheaterName); Assert.AreEqual((HttpStatusCode)200, response.StatusCode); service.DeleteTheater(theater); dbcontext.SaveChanges(); }
public void PutShouldUpdateTheater_Pass() { // Arrange var dbcontext = new BroadwayBuilderContext(); var theaterService = new TheaterService(dbcontext); var theater = new Theater("TEST", "Theater controller", "PUT", "UpdateTheater", "CA", "US", "1355"); theaterService.CreateTheater(theater); dbcontext.SaveChanges(); var theaterController = new TheaterController(); // Act theater.State = "CHANGED DATA"; theater.City = "CHANGED DATA"; theater.PhoneNumber = "CHanged DATA"; var actionResult = theaterController.UpdateTheater(theater); var response = actionResult as NegotiatedContentResult <Theater>; var content = response.Content; theaterService.DeleteTheater(theater); dbcontext.SaveChanges(); // Assert Assert.IsNotNull(response); Assert.IsNotNull(content); Assert.AreEqual((HttpStatusCode)200, response.StatusCode); }
public void Can_Paginate1() { // Arrange Mock <ITheaterRepository> mock = new Mock <ITheaterRepository>(); mock.Setup(t => t.Theaters).Returns(new Theater[] { new Theater { TheaterID = 1, TheaterName = "T1" }, new Theater { TheaterID = 2, TheaterName = "T2" }, new Theater { TheaterID = 3, TheaterName = "T3" }, new Theater { TheaterID = 4, TheaterName = "T4" }, new Theater { TheaterID = 5, TheaterName = "T5" } }); TheaterController controller = new TheaterController(mock.Object); controller.PageSize = 3; // Act TheatersListViewModel result = (TheatersListViewModel)controller.List(2).Model; // Assert Theater[] TheaterArray = result.ToArray(); Assert.IsTrue(TheaterArray.Length == 2); Assert.AreEqual(TheaterArray[0].TheaterName, "T4"); Assert.AreEqual(TheaterArray[1].TheaterName, "T5"); }
private void Update() { if (theaterController == null) { theaterController = GameObject.Find("Theater(Clone)").GetComponent <TheaterController>(); } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
public void GetCities_InternalServerError_Test() { var theaterServiceMock = new Mock <ITheaterService>(); theaterServiceMock.Setup(x => x.GetCities()).Throws <Exception>(); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetCities(); var result = (ObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(result.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"] == false); theaterServiceMock.VerifyAll(); }
public void GetMovieTicketTypes_Successfully_Test() { var theaterServiceMock = new Mock <ITheaterService>(); theaterServiceMock.Setup(x => x.GetMovieTicketTypes()); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetMovieTicketTypes(); var okResult = (OkObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(okResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"]); theaterServiceMock.VerifyAll(); }
public void GetMovieTitleAndSummaryById_NullValue_Test() { var theaterServiceMock = new Mock <ITheaterService>(); Guid id = new Guid(); theaterServiceMock.Setup(x => x.GetMovieTitleAndSummaryById(id)).Throws <ArgumentException>(); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetMovieTitleAndSummaryById(id); var badRequestResult = (BadRequestObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(badRequestResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"] == false); theaterServiceMock.VerifyAll(); }
public void GetTheatersByCity_CityNullValue_Test() { var theaterServiceMock = new Mock <ITheaterService>(); string city = ""; theaterServiceMock.Setup(x => x.GetTheatersByCity(city)).Throws <ArgumentNullException>(); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetTheaters(city); var badRequestResult = (BadRequestObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(badRequestResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"] == false); theaterServiceMock.VerifyAll(); }
public void GetPagesCount_SizeLessThanZero_Test() { var theaterServiceMock = new Mock <ITheaterService>(); int size = new int(); theaterServiceMock.Setup(x => x.GetPagesCount(size)).Throws(new InvalidOperationException("Size should be positive numbers.")); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetPagesCount(size); var badRequestResult = (BadRequestObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(badRequestResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.AreEqual("Size should be positive numbers.", deserialized["Error"]); theaterServiceMock.VerifyAll(); }
public void GetTimetableAvailableTickets_InternalServerError_Test() { var theaterServiceMock = new Mock <ITheaterService>(); Guid timetableId = new Guid(); theaterServiceMock.Setup(x => x.GetTimetableAvailableTickets(timetableId)) .Throws <Exception>(); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.GetTimetableAvailableTickets(timetableId); var badRequestResult = (ObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(badRequestResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"] == false); theaterServiceMock.VerifyAll(); }
public void DeleteShouldDeleteTheater_Pass() { // Arrange var dbcontext = new BroadwayBuilderContext(); var theaterService = new TheaterService(dbcontext); var theater = new Theater("TEST", "Theater controller", "PUT", "UpdateTheater", "CA", "US", "1355"); theaterService.CreateTheater(theater); dbcontext.SaveChanges(); var theaterController = new TheaterController(); // Act var actionResult = theaterController.DeleteTheater(theater); var response = actionResult as NegotiatedContentResult <String>; var content = response.Content; // Assert Assert.IsNotNull(response); Assert.IsNotNull(content); Assert.AreEqual((HttpStatusCode)200, response.StatusCode); }
public void BookTicket_Successful_Test() { var theaterServiceMock = new Mock <ITheaterService>(); Guid id = new Guid(); UserBookTicketDto user = new UserBookTicketDto(); int numberOfTickets = new int(); theaterServiceMock.Setup(x => x.BookTicket(id, numberOfTickets, user)); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.BookTicket(id, numberOfTickets, user); var okResult = (OkObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(okResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"]); theaterServiceMock.VerifyAll(); }
public void BookTicket_NullValue_Test() { var theaterServiceMock = new Mock <ITheaterService>(); Guid id = new Guid(); UserBookTicketDto user = new UserBookTicketDto(); int numberOfTickets = new int(); theaterServiceMock.Setup(x => x.BookTicket(id, numberOfTickets, user)).Throws <ArgumentException>(); var controller = new TheaterController(theaterServiceMock.Object); var actualResult = controller.BookTicket(id, numberOfTickets, user); var badRequestResult = (BadRequestObjectResult)actualResult; var asJson = JsonConvert.SerializeObject(badRequestResult.Value); var deserialized = JsonConvert.DeserializeObject <Dictionary <string, object> >(asJson); Assert.IsTrue((bool)deserialized["Success"] == false); theaterServiceMock.VerifyAll(); }
public void Can_Send_Pagination_View_Model1() { // Arrange Mock <ITheaterRepository> mock = new Mock <ITheaterRepository>(); mock.Setup(t => t.Theaters).Returns(new Theater[] { new Theater { TheaterID = 1, TheaterName = "T1" }, new Theater { TheaterID = 2, TheaterName = "T2" }, new Theater { TheaterID = 3, TheaterName = "T3" }, new Theater { TheaterID = 4, TheaterName = "T4" }, new Theater { TheaterID = 5, TheaterName = "T5" } }); // Arrange TheaterController controller = new TheaterController(mock.Object); controller.PageSize = 3; // Act TheatersListViewModel result = (TheatersListViewModel)controller.List(2).Model; // Assert PagingInfo pageInfo = result.PagingInfo; Assert.AreEqual(pageInfo.CurrentPage, 2); Assert.AreEqual(pageInfo.ItemsPerPage, 3); Assert.AreEqual(pageInfo.TotalItems, 5); Assert.AreEqual(pageInfo.TotalPages, 2); }
public FormTheaterUpdate(TheaterDTO dto) { InitializeComponent(); _dto = dto; _tc = new TheaterController(); }
public FormTheaterList() { InitializeComponent(); _tc = new TheaterController(); }