public async Task Create_ReturnsACreatedAtActionResultAndAddsEpisode_WhenModelStateIsValid() { var mapper = CreateAutoMapper(); var episodeServiceMock = new Mock <IEpisodeService>(); episodeServiceMock.Setup(s => s.CreateAsync(It.IsAny <Episode>())) .Returns(Task.FromResult(new Episode())) .Verifiable(); var controller = new EpisodeController(mapper, episodeServiceMock.Object); var episode = new CreateEpisodeViewModel { Title = "Episode 1", VideoId = "aljklasf" }; var result = await controller.Create(episode); var createdAtActionResult = Assert.IsType <CreatedAtActionResult>(result); Assert.Equal("GetById", createdAtActionResult.ActionName); Assert.IsType <EpisodeViewModel>(createdAtActionResult.Value); episodeServiceMock.Verify(); }
public async Task GetById_ReturnsAObjectResult_WithAEpisodeViewModel() { var mapper = CreateAutoMapper(); var episode = new Episode { Id = 1, Title = "Best of the Worst #1", VideoId = "adfjl" }; var episodeServiceMock = new Mock <IEpisodeService>(); episodeServiceMock.Setup(s => s.GetByIdAsync(It.IsAny <long>())) .Returns(Task.FromResult(episode)); var controller = new EpisodeController(mapper, episodeServiceMock.Object); var result = await controller.GetById(1); var objectResult = Assert.IsType <ObjectResult>(result); var model = Assert.IsAssignableFrom <EpisodeViewModel>(objectResult.Value); Assert.Equal(1, model.Id); }
void Start() { episode_controller = GameObject.Find("EpisodeController").GetComponent <EpisodeController> (); agent_player1_red = episode_controller.GetPlayer1Ref(true); agent_player2_red = episode_controller.GetPlayer2Ref(true); agent_player1_green = episode_controller.GetPlayer1Ref(false); agent_player2_green = episode_controller.GetPlayer2Ref(false); Debug.Log(agent_player1_red == null); }
public MainWindow() { InitializeComponent(); podcastController = new PodcastController(); episodeController = new EpisodeController(); categoryController = new CategoryController(); podcasts = podcastController.GetPodcasts(); FillPodcastList(); FillCategoryList(); FillCategoryComboBox(); InitTimers(); }
public Main() { InitializeComponent(); DataContext = App.ViewModel; App.MainPage = this; this.showController = new ShowController(); this.episodeController = new EpisodeController(); this.userController = new UserController(); this.movieController = new MovieController(); this.Loading = false; this.Loaded += new RoutedEventHandler(MainPage_Loaded); }
public frmRss() { InitializeComponent(); _categoryController = new CategoryController(); _podcastController = new PodCastController(); _episodeController = new EpisodeController(); _timer = new Timer(); FillIntervallComboBox(); FillCategoryComboBox(); ShowCategory(); ShowPodCastSubscriptions(); _timer.Interval = 5000; _timer.Tick += Timer_Tick; _timer.Start(); }
public async Task GetById_ReturnsNotFound_WhenEpisodeIsNull() { var mapper = CreateAutoMapper(); var episodeServiceMock = new Mock <IEpisodeService>(); episodeServiceMock.Setup(s => s.GetByIdAsync(It.IsAny <long>())) .Returns(Task.FromResult((Episode)null)); var controller = new EpisodeController(mapper, episodeServiceMock.Object); var result = await controller.GetById(23); Assert.IsType <NotFoundResult>(result); }
public async Task GetAll_ReturnsAnIEnumerableOfEpisodeViewModels() { var mapper = CreateAutoMapper(); var episodeServiceMock = new Mock <IEpisodeService>(); episodeServiceMock.Setup(s => s.ListAllAsync()) .Returns(Task.FromResult(GetTestEpisodes())); var controller = new EpisodeController(mapper, episodeServiceMock.Object); var result = await controller.GetAll(); Assert.IsType <List <EpisodeViewModel> >(result); }
private void ViewEpisode_Loaded(object sender, RoutedEventArgs e) { LayoutRoot.Opacity = 1; if (!App.EpisodeViewModel.IsDataLoaded) { this.episodeController = new EpisodeController(); this.showController = new ShowController(); LoadingActive = false; LoadEpisode(); } this.EpisodePanorama.SelectedIndex = lastIndex; }
private NotificationObject GetEpisodeTimeGateReadyNotif() { EpisodeController episodeController = Service.EpisodeController; if (!episodeController.IsTaskTimeGateActive()) { return(null); } uint taskTimeGateEndTime = episodeController.GetTaskTimeGateEndTime(); uint serverTime = Service.ServerAPI.ServerTime; if (serverTime > taskTimeGateEndTime) { return(null); } int num = (int)(taskTimeGateEndTime - serverTime); DateTime time = DateTime.Now.AddSeconds((double)num); return(this.CreateReengagementNotification("episode_research", time, false)); }
public async Task Create_ReturnsBadRequestResult_WhenModelStateIsInvalid() { var mapper = CreateAutoMapper(); var episodeServiceMock = new Mock <IEpisodeService>(); episodeServiceMock.Setup(s => s.CreateAsync(It.IsAny <Episode>())) .Returns(Task.FromResult(new Episode())); var controller = new EpisodeController(mapper, episodeServiceMock.Object); controller.ModelState.AddModelError("Title", "A title is required"); var newEpisode = new CreateEpisodeViewModel(); var result = await controller.Create(newEpisode); var badRequestResult = Assert.IsType <BadRequestObjectResult>(result); Assert.IsType <SerializableError>(badRequestResult.Value); }
private void ViewShow_Loaded(object sender, RoutedEventArgs e) { this.ShowPanorama.SelectedIndex = lastIndex; this.showController = new ShowController(); this.episodeController = new EpisodeController(); this.LoadingActive = false; String tvdb; NavigationContext.QueryString.TryGetValue("id", out tvdb); if (!String.IsNullOrEmpty(App.ShowViewModel.Tvdb)) { RefreshBottomBar(); } if (!this.LoadingActive) { this.LoadingActive = true; LoadShow(tvdb); this.LoadingActive = false; } }
private async void client_UploadRatingStringCompleted(object sender, UploadStringCompletedEventArgs e) { try { String jsonString = e.Result; if (type.Equals("movie")) { String imdb; Int16 rating = Int16.Parse(this.selector.DataSource.SelectedItem.ToString()); NavigationContext.QueryString.TryGetValue("imdb", out imdb); MovieController controller = new MovieController(); TraktMovie movie = await controller.getMovieByImdbId(imdb); movie.MyRatingAdvanced = rating; if (rating > 5) { movie.MyRating = "Loved"; } else { movie.MyRating = "Hated"; } controller.updateMovie(movie); } else if (type.Equals("show")) { String imdb; String tvdb; Int16 rating = Int16.Parse(this.selector.DataSource.SelectedItem.ToString()); NavigationContext.QueryString.TryGetValue("imdb", out imdb); NavigationContext.QueryString.TryGetValue("tvdb", out tvdb); ShowController controller = new ShowController(); TraktShow show = controller.getShowByIMDBID(imdb); if (show == null) { show = await controller.getShowByTVDBID(tvdb); } show.MyRatingAdvanced = rating; if (rating > 5) { show.MyRating = "Loved"; } else { show.MyRating = "Hated"; } if (App.ShowViewModel != null) { App.ShowViewModel.MyRating = "true"; App.ShowViewModel.MyRatingAdvanced = rating; } controller.updateShow(show); } else if (type.Equals("episode")) { String imdb; String tvdbId; String year; String title; String season; String episode; NavigationContext.QueryString.TryGetValue("imdb", out imdb); NavigationContext.QueryString.TryGetValue("tvdb", out tvdbId); NavigationContext.QueryString.TryGetValue("year", out year); NavigationContext.QueryString.TryGetValue("title", out title); NavigationContext.QueryString.TryGetValue("season", out season); NavigationContext.QueryString.TryGetValue("episode", out episode); Int16 rating = Int16.Parse(this.selector.DataSource.SelectedItem.ToString()); EpisodeController controller = new EpisodeController(); ShowController showController = new ShowController(); TraktShow show = await showController.getShowByTVDBID(tvdbId); TraktEpisode traktEpisode = await controller.getEpisodeByTvdbAndSeasonInfo(tvdbId, season, episode, show); traktEpisode.MyRatingAdvanced = rating; if (rating > 5) { traktEpisode.MyRating = "Loved"; } else { traktEpisode.MyRating = "Hated"; } if (controller.updateEpisode(traktEpisode)) { if (App.ShowViewModel != null && !String.IsNullOrEmpty(App.ShowViewModel.Tvdb) && App.ShowViewModel.Tvdb.Equals(show.tvdb_id)) { App.ShowViewModel.updateEpisode(traktEpisode); } if (App.EpisodeViewModel != null && !String.IsNullOrEmpty(App.EpisodeViewModel.Tvdb) && App.EpisodeViewModel.Tvdb.Equals(show.tvdb_id)) { App.EpisodeViewModel.MyRating = "true"; App.EpisodeViewModel.MyRatingAdvanced = rating; } } else { ErrorManager.ShowConnectionErrorPopup(); NavigationService.GoBack(); } } MessageBox.Show("Rated successfull."); } catch (WebException) { ErrorManager.ShowConnectionErrorPopup(); } catch (TargetInvocationException) { ErrorManager.ShowConnectionErrorPopup(); } NavigationService.GoBack(); }
void Start() { episode_controller = GameObject.Find("EpisodeController").GetComponent <EpisodeController> (); }