public void TestGetMetadata() { // Test 1: Normal case. MovieInfo info = new MovieInfo() { Name = "源代码" }; var meta = _provider.GetMetadata(info, CancellationToken.None).Result; Assert.True(meta.HasMetadata); Assert.Equal("源代码", meta.Item.Name); Assert.Equal("Source Code", meta.Item.OriginalTitle); Assert.Equal("3075287", meta.Item.GetProviderId(OddbPlugin.ProviderId)); Assert.Equal(DateTime.Parse("2011-08-30"), meta.Item.PremiereDate); // Test 2: Already has provider Id. info = new MovieInfo() { Name = "Source Code" }; info.SetProviderId(OddbPlugin.ProviderId, "1851857"); meta = _provider.GetMetadata(info, CancellationToken.None).Result; Assert.True(meta.HasMetadata); Assert.Equal("蝙蝠侠:黑暗骑士", meta.Item.Name); }
public void TestGetSearchResults() { // Test 1: search metadata. MovieInfo info = new MovieInfo() { Name = "蝙蝠侠.黑暗骑士", }; var result = _provider.GetSearchResults(info, CancellationToken.None).Result; Assert.NotEmpty(result); Assert.True(result.Count() > 1); string doubanId = result.FirstOrDefault()?.GetProviderId(OddbPlugin.ProviderId); int? year = result.FirstOrDefault()?.ProductionYear; Assert.Equal("1851857", doubanId); Assert.Equal(2008, year); // Test 2: Already has provider Id. info.SetProviderId(OddbPlugin.ProviderId, "1851857"); result = _provider.GetSearchResults(info, CancellationToken.None).Result; Assert.True(result.Count() == 1); doubanId = result.FirstOrDefault()?.GetProviderId(OddbPlugin.ProviderId); year = result.FirstOrDefault()?.ProductionYear; Assert.Equal("1851857", doubanId); Assert.Equal(2008, year); }