- Parsed the ChangeItem Time property

- Expanded tests
This commit is contained in:
Michael Bisbjerg 2013-02-13 20:26:59 +01:00
parent 953b4880ae
commit 9b434d079f
3 changed files with 60 additions and 5 deletions

View File

@ -1,4 +1,7 @@
namespace TMDbLib.Objects.Movies
using System;
using System.Globalization;
namespace TMDbLib.Objects.Movies
{
public class ChangeItem
{
@ -7,5 +10,14 @@
public string Time { get; set; } // TODO: Datetype
public string Iso_639_1 { get; set; }
public string Value { get; set; }
public DateTime TimeParsed
{
get
{
// Parse the Time, it's always in UTC format
return DateTime.Parse(Time.Replace(" UTC", ""), CultureInfo.GetCultureInfo("en-US"), DateTimeStyles.AssumeUniversal);
}
}
}
}

View File

@ -45,7 +45,7 @@ namespace TMDbLibTests
// Get movies
SearchContainerWithId<MovieResult> movies = _config.Client.GetGenreMovies(genre.Id);
SearchContainerWithId<MovieResult> moviesPage2 = _config.Client.GetGenreMovies(genre.Id, 2);
SearchContainerWithId<MovieResult> moviesPage2 = _config.Client.GetGenreMovies(genre.Id, "it", 2, includeAllMovies: false);
SearchContainerWithId<MovieResult> moviesAll = _config.Client.GetGenreMovies(genre.Id, includeAllMovies: true);
Assert.AreEqual(1, movies.Page);
@ -60,7 +60,7 @@ namespace TMDbLibTests
Assert.IsTrue(moviesPage2.Results.All(s => s != null));
Assert.IsTrue(moviesAll.Results.All(s => s != null));
Assert.AreEqual(movies.TotalResults, moviesPage2.TotalResults);
Assert.AreEqual(movies.TotalResults, moviesPage2.TotalResults); // Should be the same, despite the use of 'includeAllMovies' and Italian
Assert.IsTrue(moviesAll.TotalResults > movies.TotalResults);
}
}

View File

@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TMDbLib.Objects.General;
using TMDbLib.Objects.Movies;
@ -98,8 +100,17 @@ namespace TMDbLibTests
{
//GetMovieAlternativeTitles(int id, string country)
{
var resp = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard);
Assert.IsNotNull(resp);
var respUs = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "US");
Assert.IsNotNull(respUs);
var respGerman = _config.Client.GetMovieAlternativeTitles(AGoodDayToDieHard, "DE");
Assert.IsNotNull(respGerman);
Assert.IsFalse(respUs.Titles.Any(s => s.Title == "Stirb Langsam 5"));
Assert.IsTrue(respGerman.Titles.Any(s => s.Title == "Stirb Langsam 5"));
Assert.IsTrue(respUs.Titles.All(s => s.Iso_3166_1 == "US"));
Assert.IsTrue(respGerman.Titles.All(s => s.Iso_3166_1 == "DE"));
}
//GetMovieCasts(int id)
@ -142,20 +153,52 @@ namespace TMDbLibTests
{
var resp = _config.Client.GetMovieSimilarMovies(AGoodDayToDieHard);
Assert.IsNotNull(resp);
var respGerman = _config.Client.GetMovieSimilarMovies(AGoodDayToDieHard, language: "de");
Assert.IsNotNull(respGerman);
Assert.AreEqual(resp.Results.Count, respGerman.Results.Count);
Assert.AreEqual(resp.Results.First().Id, respGerman.Results.First().Id);
Assert.AreNotEqual(resp.Results.First().Title, respGerman.Results.First().Title);
}
//GetMovieLists(int id, string language, int page = -1)
{
var resp = _config.Client.GetMovieLists(AGoodDayToDieHard);
Assert.IsNotNull(resp);
var respPage2 = _config.Client.GetMovieLists(AGoodDayToDieHard, 2);
Assert.IsNotNull(respPage2);
Assert.AreEqual(1, resp.Page);
Assert.AreEqual(2, respPage2.Page);
Assert.AreEqual(resp.TotalResults, resp.TotalResults);
}
//GetMovieChanges(int id, DateTime? startDate = null, DateTime? endDate = null)
{
var resp = _config.Client.GetMovieChanges(AGoodDayToDieHard);
Assert.IsNotNull(resp);
DateTime lower = DateTime.UtcNow.AddDays(-14);
DateTime higher = DateTime.UtcNow;
var respRange = _config.Client.GetMovieChanges(AGoodDayToDieHard, lower, higher);
Assert.IsNotNull(respRange);
// As TMDb works in days, we need to adjust our values also
lower = lower.AddDays(-1);
higher = higher.AddDays(1);
foreach (Change change in respRange)
foreach (ChangeItem changeItem in change.Items)
{
DateTime date = changeItem.TimeParsed;
Assert.IsTrue(lower <= date);
Assert.IsTrue(date <= higher);
}
}
}
[TestMethod]