private void buttonAddMovie_Click(object sender, EventArgs e) { Movie newMovie = new Movie(CurrentMovie.Name, CurrentMovie.Length); AllMovies.Add(newMovie); textBoxAllMovies.Text += CurrentMovie.Name + ", " + CurrentMovie.Length + " min." + Environment.NewLine; }
public IEnumerable <string> GetMovieTitles(string query) { return(AllMovies .Where(c => c.Title.IndexOf(query, StringComparison.CurrentCultureIgnoreCase) > -1) .OrderByDescending(c => c.Title.StartsWith(query, StringComparison.CurrentCultureIgnoreCase)) .Select(c => c.Title).Distinct()); }
internal static ZumoTest CreatePopulateTableTest() { return(new ZumoTest("Populate movies table, if necessary", new TestExecution(async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var table = client.GetTable <AllMovies>(); AllMovies allMovies = new AllMovies { Movies = ZumoQueryTestData.AllMovies }; await table.InsertAsync(allMovies); for (int i = 0; i < 20; i++) { var counter = await table.Take(0).IncludeTotalCount().ToListAsync(); var totalCount = ((ITotalCountProvider)counter).TotalCount; if (totalCount == allMovies.Movies.Length) { test.AddLog("Result of populating table: {0}", allMovies.Status); return true; } else { test.AddLog("Already inserted {0} items, waiting for insertion to complete", totalCount); await Util.TaskDelay(5000); } } test.AddLog("Result of populating table: Time out. Not populate enough data."); return false; }), ZumoTestGlobals.RuntimeFeatureNames.INT_ID_TABLES)); }
private void buttonDelete_Click(object sender, EventArgs e) { AllMovies.RemoveAt(AllMovies.Count - 1); textBoxAllMovies.Clear(); for (int i = 0; i < AllMovies.Count; ++i) { textBoxAllMovies.Text += AllMovies[i].Name + ", " + AllMovies[i].Length + " min." + Environment.NewLine; } }
public MainPageViewModel() { MessagingCenter.Subscribe <MenuPageViewModel, string>(this, "SelectedGenre", (sender, selectedGenre) => { DetailPageViewModel.Movies = AllMovies.Where(m => m.Genre.Contains(MenuPageViewModel.SelectedGenre)).ToList(); }); MenuPageViewModel = new MenuPageViewModel(); DetailPageViewModel = new DetailPageViewModel(); }
public MainPageViewModel() { MessagingCenter.Subscribe <MenuPageViewModel, string>(this, "SelectedGenre", (sender, selectedGenre) => { DetailPageViewModel.Movies = AllMovies.Where(m => m.Genre.Contains(MenuPageViewModel.SelectedGenre)).ToList(); }); MessagingCenter.Subscribe <AddMoviePageViewModel>(this, "RefreshMovies", async sender => await RefreshAsync()); MessagingCenter.Subscribe <DetailPageViewModel>(this, "RefreshMovies", async sender => await RefreshAsync()); MenuPageViewModel = new MenuPageViewModel(); DetailPageViewModel = new DetailPageViewModel(); }
public async Task LoadAsync() { AllMovies.Clear(); var movies = await _movieRepository.GetAllAsync(); foreach (var movie in movies) { var modelWrapper = new MovieWrapper(movie); AllMovies.Add(modelWrapper); } }
/// <summary> /// Organize list of movies by their release date /// </summary> public static void ByDate() { if (AllMovies.Count > 0) { try { AllMovies.Sort((x, y) => y.Movie_Info.release_date.Value.CompareTo(x.Movie_Info.release_date.Value)); } catch (Exception ex) { Debug.WriteLine("Exception at Movie.Organize.ByDate() -> Message: " + ex.Message); } } }
private void buttonRandom_Click(object sender, EventArgs e) { textBoxAllMovies.Clear(); Movie Movie1 = new Movie("Lion King", 90); Movie Movie2 = new Movie("Wizard of OZ", 80); Movie Movie3 = new Movie("Mickey Mouse", 70); AllMovies.Add(Movie1); AllMovies.Add(Movie2); AllMovies.Add(Movie3); for (int i = 0; i < AllMovies.Count; ++i) { textBoxAllMovies.Text += AllMovies[i].Name + ", " + AllMovies[i].Length + " min." + Environment.NewLine; } }
internal static ZumoTest CreatePopulateTableTest() { return(new ZumoTest("Populate movies table, if necessary", new TestExecution(async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var table = client.GetTable <AllMovies>(); AllMovies allMovies = new AllMovies { Movies = ZumoQueryTestData.AllMovies }; await table.InsertAsync(allMovies); test.AddLog("Result of populating table: {0}", allMovies.Status); return true; }))); }
private async void OpenNavigationView(OpenNavigationViewEventArgs args) { await LoadAsync(); var subscription = await _subscriptionRepository.GetByIdAsync(args.Id); var movie = await _movieRepository.GetByIdAsync(subscription.MovieId); var movieWrpper = AllMovies.Where(m => m.Id == movie.Id).FirstOrDefault(); if (movieWrpper != null) { SelectedMovie = movieWrpper; } }
public DetailPageViewModel() { RefreshCommand = new Command(() => { MessagingCenter.Send <DetailPageViewModel>(this, "RefreshMovies"); }); DeleteCommand = new Command <Movie>(async movie => { await MoviesSource.RemoveMovieAsync($"{AllMovies.IndexOf(movie)}"); MessagingCenter.Send <DetailPageViewModel>(this, "RefreshMovies"); }); NavigateCommand = new Command <Movie>(movie => { MessagingCenter.Send <DetailPageViewModel, Movie>(this, "SelectedMovie", movie); }); }
/// <summary> /// Permet de changer l'ordonnancement. /// </summary> /// <param name="ordreVoulu"></param> internal void ChangeOrdre(string ordreVoulu) { switch (ordreVoulu) { case "Par date d'ajout": var tempDate = AllMovies.OrderByDescending(movie => movie.DateAdded).ToList(); AllMovies = tempDate; break; case "Par nom": var tempName = AllMovies.OrderBy(movie => movie.Titre).ToList(); AllMovies = tempName; break; default: break; } }
public ActionResult SeeAll(string pType, int?page) { ViewBag.Message = "See all"; string movieTypeName = ""; MovieListType movieType = new MovieListType(); switch (pType) { case "seeAllPopular": movieType = MovieListType.Popular; movieTypeName = "Popular"; break; case "seeAllTopRated": movieType = MovieListType.TopRated; movieTypeName = "Top Rated"; break; case "seeAllNowPlaying": movieType = MovieListType.NowPlaying; movieTypeName = "Now Playing"; break; case "seeAllUpcoming": movieType = MovieListType.Upcoming; movieTypeName = "Upcoming"; break; } TMDbClient client = new TMDbClient(ApiKey); int pageNumber = (page ?? 1); IEnumerable <MovieResult> currentAllMovies = client.GetMovieList(movieType, pageNumber).Results; AllMovies allMovies = new AllMovies(); allMovies.currentAllMovies = currentAllMovies; allMovies.currentMovieType = pType.ToString(); allMovies.currentMovieTypeName = movieTypeName; allMovies.totalPages = client.GetMovieList(movieType).TotalPages; return(View("SeeAll", allMovies)); }
public ActionResult Movies() { var movies = new List <Movie> { new Movie { Id = 101, Name = "Avengers Infinity War", Releasedate = "JUN 2018" }, new Movie { Id = 102, Name = "Baahubali", Releasedate = "MAY 2014" }, new Movie { Id = 103, Name = "Hobbs & Shaw", Releasedate = "JUL 2019" }, new Movie { Id = 104, Name = "Matrix", Releasedate = "NOV 2011" }, new Movie { Id = 105, Name = "Men in Black3", Releasedate = "APR 2014" }, new Movie { Id = 106, Name = "URI", Releasedate = "FEB 2015" }, new Movie { Id = 107, Name = "SpiderMan", Releasedate = "OCT 2017" }, new Movie { Id = 108, Name = "India", Releasedate = "AUG 2019" }, new Movie { Id = 109, Name = "Dhoni", Releasedate = "SEP 2015" }, new Movie { Id = 110, Name = "Galactic Wars", Releasedate = "MAR 2016" } }; var viewModel = new AllMovies { Movies = movies }; return(View(viewModel)); }
private async void OpenAndFilterNavigationView(OpenAndFilterNavigationViewEventArgs args) { if (String.IsNullOrEmpty(args.SelectedItem)) { await LoadAsync(); } else { var filteredMovies = AllMovies.Where(m => m.Name.ToLower().StartsWith(args.SelectedItem.ToLower())); List <MovieWrapper> tempList = new List <MovieWrapper>(); foreach (var filteredMovie in filteredMovies) { tempList.Add(filteredMovie); } AllMovies.Clear(); foreach (var item in tempList) { AllMovies.Add(item); } } }
public async Task GetMoviesDataAsync() { if (AllMovies.Count != 0) { return; } System.Diagnostics.Debug.WriteLine("getting data"); Uri dataUri = new Uri("ms-appx:///DataSource/moviespots.json"); StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri); string jsonText = await FileIO.ReadTextAsync(file); JsonObject jsonObject = JsonObject.Parse(jsonText); JsonArray jsonArray = jsonObject["MovieSpots"].GetArray(); foreach (JsonValue value in jsonArray) { JsonObject movieJsonObject = value.GetObject(); Movie movie = new Movie { Title = movieJsonObject["Title"].GetString(), ReleaseYear = movieJsonObject["Release Year"].GetString(), StreetName = movieJsonObject["Locations"].GetString(), FunFacts = movieJsonObject["Fun Facts"].GetString(), ProductionCompany = movieJsonObject["Production Company"].GetString(), Distributor = movieJsonObject["Distributor"].GetString(), Director = movieJsonObject["Director"].GetString(), Writer = movieJsonObject["Writer"].GetString(), Actor1 = movieJsonObject["Actor 1"].GetString(), Actor2 = movieJsonObject["Actor 2"].GetString(), Actor = movieJsonObject["Actor "].GetString(), Latitude = movieJsonObject["Latitude"].GetNumber(), Longitude = movieJsonObject["Longitude"].GetNumber() }; AllMovies.Add(movie); } }
private async Task CreateTypedApiTest(Random seedGenerator, TypedTestType testType) { var client = GetClient(); var apiName = MovieFinderApiName; for (int i = 0; i < 10; i++) { int seed = seedGenerator.Next(); Random rndGen = new Random(seed); Movie[] expectedResult = null; AllMovies actualResult = null; Movie inputTemplate; // TODO: BUG #2132434: .NET runtime should allow URI's that end with a dot while (true) { inputTemplate = QueryTestData.TestMovies()[rndGen.Next(QueryTestData.TestMovies().Length)]; if (testType == TypedTestType.GetByTitle && inputTemplate.Title.EndsWith(".")) { // The .NET backend barfs and returns 404 if the URI ends with a dot, so let's get another movie continue; } if (testType == TypedTestType.GetByTitle && inputTemplate.Title.EndsWith("?")) { // The .NET & Node backend do not return anything if the URI ends with a '?' so let's get another movie continue; } break; } string apiUrl; switch (testType) { case TypedTestType.GetByTitle: apiUrl = apiName + "/title/" + inputTemplate.Title; expectedResult = new Movie[] { inputTemplate }; actualResult = await client.InvokeApiAsync <AllMovies>(apiUrl, HttpMethod.Get, null); break; case TypedTestType.GetByDate: var releaseDate = inputTemplate.ReleaseDate; apiUrl = apiName + "/date/" + releaseDate.Year + "/" + releaseDate.Month + "/" + releaseDate.Day; expectedResult = QueryTestData.TestMovies().Where(m => m.ReleaseDate == releaseDate).ToArray(); actualResult = await client.InvokeApiAsync <AllMovies>(apiUrl, HttpMethod.Get, null); break; case TypedTestType.PostByDuration: case TypedTestType.PostByYear: string orderBy = null; switch (rndGen.Next(3)) { case 0: orderBy = null; break; case 1: orderBy = "id"; break; case 2: orderBy = "Title"; break; } Dictionary <string, string> queryParams = orderBy == null ? null : new Dictionary <string, string> { { "orderBy", orderBy } }; Func <Movie, bool> predicate; if (testType == TypedTestType.PostByYear) { predicate = m => m.Year == inputTemplate.Year; apiUrl = apiName + "/moviesOnSameYear"; } else { predicate = m => m.Duration == inputTemplate.Duration; apiUrl = apiName + "/moviesWithSameDuration"; } if (queryParams == null) { actualResult = await client.InvokeApiAsync <Movie, AllMovies>(apiUrl, inputTemplate); } else { actualResult = await client.InvokeApiAsync <Movie, AllMovies>(apiUrl, inputTemplate, HttpMethod.Post, queryParams); } expectedResult = QueryTestData.TestMovies().Where(predicate).ToArray(); if (orderBy == null || orderBy == "Title") { Array.Sort(expectedResult, (m1, m2) => m1.Title.CompareTo(m2.Title)); } break; default: throw new ArgumentException("Invalid test type: " + testType); } List <string> errors = new List <string>(); var actual = actualResult.Movies; Assert.True(!expectedResult.Except(actual).Any() && expectedResult.Length == actual.Length); } }
internal static ZumoTestGroup CreateTests() { ZumoTestGroup result = new ZumoTestGroup("Query tests"); result.AddTest(new ZumoTest("Populate table, if necessary", new TestExecution(async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var table = client.GetTable <AllMovies>(); AllMovies allMovies = new AllMovies { Movies = ZumoQueryTestData.AllMovies }; await table.InsertAsync(allMovies); test.AddLog("Result of populating table: {0}", allMovies.Status); return(true); }))); // Numeric fields result.AddTest(CreateQueryTest("GreaterThan and LessThan - Movies from the 90s", m => m.Year > 1989 && m.Year < 2000)); result.AddTest(CreateQueryTest("GreaterEqual and LessEqual - Movies from the 90s", m => m.Year >= 1990 && m.Year <= 1999)); result.AddTest(CreateQueryTest("Compound statement - OR of ANDs - Movies from the 30s and 50s", m => ((m.Year >= 1930) && (m.Year < 1940)) || ((m.Year >= 1950) && (m.Year < 1960)))); result.AddTest(CreateQueryTest("Division, equal and different - Movies from the year 2000 with rating other than R", m => ((m.Year / 1000.0) == 2) && (m.MPAARating != "R"))); result.AddTest(CreateQueryTest("Addition, subtraction, relational, AND - Movies from the 1980s which last less than 2 hours", m => ((m.Year - 1900) >= 80) && (m.Year + 10 < 2000) && (m.Duration < 120))); // String functions result.AddTest(CreateQueryTest("String: StartsWith - Movies which starts with 'The'", m => m.Title.StartsWith("The"), 100)); result.AddTest(CreateQueryTest("String: StartsWith, case insensitive - Movies which start with 'the'", m => m.Title.ToLower().StartsWith("the"), 100)); result.AddTest(CreateQueryTest("String: EndsWith, case insensitive - Movies which end with 'r'", m => m.Title.ToLower().EndsWith("r"))); result.AddTest(CreateQueryTest("String: Contains - Movies which contain the word 'one', case insensitive", m => m.Title.ToUpper().Contains("ONE"))); result.AddTest(CreateQueryTest("String: Length - Movies with small names", m => m.Title.Length < 10, 200)); result.AddTest(CreateQueryTest("String: Substring (1 parameter), length - Movies which end with 'r'", m => m.Title.Substring(m.Title.Length - 1) == "r")); result.AddTest(CreateQueryTest("String: Substring (2 parameters), length - Movies which end with 'r'", m => m.Title.Substring(m.Title.Length - 1, 1) == "r")); result.AddTest(CreateQueryTest("String: Replace - Movies ending with either 'Part 2' or 'Part II'", m => m.Title.Replace("II", "2").EndsWith("Part 2"))); result.AddTest(CreateQueryTest("String: Concat - Movies rated 'PG' or 'PG-13' from the 2000s", m => m.Year >= 2000 && string.Concat(m.MPAARating, "-13").StartsWith("PG-13"))); // String fields result.AddTest(CreateQueryTest("String equals - Movies since 1980 with rating PG-13", m => m.Year >= 1980 && m.MPAARating == "PG-13", 100)); result.AddTest(CreateQueryTest("String field, comparison to null - Movies since 1980 without a MPAA rating", m => m.Year >= 1980 && m.MPAARating == null)); result.AddTest(CreateQueryTest("String field, comparison (not equal) to null - Movies before 1970 with a MPAA rating", m => m.Year < 1970 && m.MPAARating != null)); // Numeric functions result.AddTest(CreateQueryTest("Floor - Movies which last more than 3 hours", m => Math.Floor(m.Duration / 60.0) >= 3)); result.AddTest(CreateQueryTest("Ceiling - Best picture winners which last at most 2 hours", m => m.BestPictureWinner == true && Math.Ceiling(m.Duration / 60.0) == 2)); result.AddTest(CreateQueryTest("Round - Best picture winners which last more than 2.5 hours", m => m.BestPictureWinner == true && Math.Round(m.Duration / 60.0) > 2)); // Date fields result.AddTest(CreateQueryTest("Date: Greater than, less than - Movies with release date in the 70s", m => m.ReleaseDate > new DateTime(1969, 12, 31, 0, 0, 0, DateTimeKind.Utc) && m.ReleaseDate < new DateTime(1971, 1, 1, 0, 0, 0, DateTimeKind.Utc))); result.AddTest(CreateQueryTest("Date: Greater than, less than - Movies with release date in the 80s", m => m.ReleaseDate >= new DateTime(1980, 1, 1, 0, 0, 0, DateTimeKind.Utc) && m.ReleaseDate < new DateTime(1989, 12, 31, 23, 59, 59, DateTimeKind.Utc))); result.AddTest(CreateQueryTest("Date: Equal - Movies released on 1994-10-14 (Shawshank Redemption / Pulp Fiction)", m => m.ReleaseDate == new DateTime(1994, 10, 14, 0, 0, 0, DateTimeKind.Utc))); // Date functions result.AddTest(CreateQueryTest("Date (month): Movies released in November", m => m.ReleaseDate.Month == 11)); result.AddTest(CreateQueryTest("Date (day): Movies released in the first day of the month", m => m.ReleaseDate.Day == 1)); result.AddTest(CreateQueryTest("Date (year): Movies whose year is different than its release year", m => m.ReleaseDate.Year != m.Year, 100)); // Bool fields result.AddTest(CreateQueryTest("Bool: equal to true - Best picture winners before 1950", m => m.Year < 1950 && m.BestPictureWinner == true)); result.AddTest(CreateQueryTest("Bool: equal to false - Best picture winners after 2000", m => m.Year >= 2000 && !(m.BestPictureWinner == false))); result.AddTest(CreateQueryTest("Bool: not equal to false - Best picture winners after 2000", m => m.BestPictureWinner != false && m.Year >= 2000)); // Top and skip result.AddTest(CreateQueryTest("Get all using large $top - 500", null, 500)); result.AddTest(CreateQueryTest("Skip all using large skip - 500", null, null, 500)); result.AddTest(CreateQueryTest("Skip, take, includeTotalCount - movies 11-20, ordered by title", null, 10, 10, new[] { new OrderByClause("Title", true) }, null, true)); result.AddTest(CreateQueryTest("Skip, take, filter includeTotalCount - movies 11-20 which won a best picture award, ordered by year", m => m.BestPictureWinner == true, 10, 10, new[] { new OrderByClause("Year", false) }, null, true)); // Order by result.AddTest(CreateQueryTest("Order by date and string - 50 movies, ordered by release date, then title", null, 50, null, new[] { new OrderByClause("ReleaseDate", false), new OrderByClause("Title", true) })); result.AddTest(CreateQueryTest("Order by number - 30 shortest movies since 1970", m => m.Year >= 1970, 30, null, new[] { new OrderByClause("Duration", true), new OrderByClause("Title", true) }, null, true)); // Select result.AddTest(CreateQueryTest("Select one field - Only title of movies from 2008", m => m.Year == 2008, null, null, null, m => m.Title)); result.AddTest(CreateQueryTest("Select multiple fields - Nicely formatted list of movies from the 2000's", m => m.Year >= 2000, 200, null, new[] { new OrderByClause("ReleaseDate", false), new OrderByClause("Title", true) }, m => string.Format("{0} {1} - {2} minutes", m.Title.PadRight(30), m.BestPictureWinner ? "(best picture)" : "", m.Duration))); // Negative tests result.AddTest(CreateQueryTest <MobileServiceInvalidOperationException>("(Neg) Very large top value", m => m.Year > 2000, 1001)); result.AddTest(CreateQueryTest <NotSupportedException>("(Neg) Unsupported predicate: unsupported arithmetic", m => Math.Sqrt(m.Year) > 43)); // Invalid lookup for (int i = -1; i <= 0; i++) { int id = i; result.AddTest(new ZumoTest("(Neg) Invalid id for lookup: " + i, async delegate(ZumoTest test) { var table = ZumoTestGlobals.Instance.Client.GetTable <Movie>(); try { var item = await table.LookupAsync(id); test.AddLog("Error, LookupAsync for id = {0} should have failed, but succeeded: {1}", id, item); return(false); } catch (MobileServiceInvalidOperationException ex) { test.AddLog("Caught expected exception - {0}: {1}", ex.GetType().FullName, ex.Message); return(true); } })); } result.AddTest(ZumoTestCommon.CreateTestWithSingleAlert("The next test will show a dialog with certain movies. Please validate that movie titles and release years are shown correctly in the list.")); result.AddTest(new ZumoTest("ToCollectionView - displaying movies on a ListBox", async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var table = client.GetTable <Movie>(); var query = from m in table where m.Year > 1980 orderby m.ReleaseDate descending select new { Date = m.ReleaseDate.ToUniversalTime().ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), Title = m.Title }; var newPage = new MoviesDisplayPage(); newPage.SetMoviesSource(query.ToCollectionView()); await newPage.Display(); return(true); })); result.AddTest(ZumoTestCommon.CreateYesNoTest("Were the movies displayed correctly?", true)); return(result); }
private static ZumoTest CreateTypedApiTest(Random seedGenerator, TypedTestType testType) { string testName = "Typed overload - " + testType; return(new ZumoTest(testName, async delegate(ZumoTest test) { var client = ZumoTestGlobals.Instance.Client; var apiName = MovieFinderApiName; var testResult = true; for (int i = 0; i < 10; i++) { int seed = seedGenerator.Next(); test.AddLog("Test with seed = {0}", seed); Random rndGen = new Random(seed); Movie[] expectedResult = null; AllMovies actualResult = null; Movie inputTemplate = ZumoQueryTestData.AllMovies[rndGen.Next(ZumoQueryTestData.AllMovies.Length)]; test.AddLog("Using movie '{0}' as template", inputTemplate.Title); string apiUrl; switch (testType) { case TypedTestType.GetByTitle: apiUrl = apiName + "/title/" + inputTemplate.Title; expectedResult = new Movie[] { inputTemplate }; actualResult = await client.InvokeApiAsync <AllMovies>(apiUrl, HttpMethod.Get, null); break; case TypedTestType.GetByDate: var releaseDate = inputTemplate.ReleaseDate; apiUrl = apiName + "/date/" + releaseDate.Year + "/" + releaseDate.Month + "/" + releaseDate.Day; expectedResult = ZumoQueryTestData.AllMovies.Where(m => m.ReleaseDate == releaseDate).ToArray(); actualResult = await client.InvokeApiAsync <AllMovies>(apiUrl, HttpMethod.Get, null); break; case TypedTestType.PostByDuration: case TypedTestType.PostByYear: string orderBy = null; switch (rndGen.Next(3)) { case 0: orderBy = null; break; case 1: orderBy = "id"; break; case 2: orderBy = "Title"; break; } Dictionary <string, string> queryParams = orderBy == null ? null : new Dictionary <string, string> { { "orderBy", orderBy } }; Func <Movie, bool> predicate; if (testType == TypedTestType.PostByYear) { predicate = m => m.Year == inputTemplate.Year; apiUrl = apiName + "/moviesOnSameYear"; } else { predicate = m => m.Duration == inputTemplate.Duration; apiUrl = apiName + "/moviesWithSameDuration"; } if (queryParams == null) { actualResult = await client.InvokeApiAsync <Movie, AllMovies>(apiUrl, inputTemplate); } else { actualResult = await client.InvokeApiAsync <Movie, AllMovies>(apiUrl, inputTemplate, HttpMethod.Post, queryParams); } expectedResult = ZumoQueryTestData.AllMovies.Where(predicate).ToArray(); if (orderBy == null || orderBy == "Title") { Array.Sort(expectedResult, (m1, m2) => m1.Title.CompareTo(m2.Title)); } break; default: throw new ArgumentException("Invalid test type: " + testType); } test.AddLog(" - Sent request to {0}", apiUrl); List <string> errors = new List <string>(); if (Util.CompareArrays(expectedResult, actualResult.Movies, errors)) { test.AddLog(" - Result is expected"); } else { foreach (var error in errors) { test.AddLog(" - {0}", error); } test.AddLog("Expected: {0}", string.Join(", ", expectedResult.Select(m => m.Title))); test.AddLog("Actual: {0}", string.Join(", ", actualResult.Movies.Select(m => m.Title))); testResult = false; break; } } return testResult; })); }
public Movie GetMovieById(int movieId) { return(AllMovies.FirstOrDefault(m => m.MovieId == movieId)); }