Add nfo user data tests

pull/5194/head
David Ullmer 4 years ago
parent dc2f8b5e6b
commit ae57ed4ac7

@ -401,7 +401,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers
break;
}
case "lasplayed":
case "lastplayed":
{
var val = reader.ReadElementContentAsString();
if (!string.IsNullOrWhiteSpace(val) && userData != null)

@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Threading;
using Jellyfin.Data.Entities;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
@ -18,19 +19,35 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
public class MovieNfoParserTests
{
private readonly MovieNfoParser _parser;
private readonly IUserDataManager _userDataManager;
private readonly User _testUser;
public MovieNfoParserTests()
{
_testUser = new User("Test User", "Auth provider", "Reset provider");
var providerManager = new Mock<IProviderManager>();
providerManager.Setup(x => x.GetExternalIdInfos(It.IsAny<IHasProviderIds>()))
.Returns(Enumerable.Empty<ExternalIdInfo>());
var config = new Mock<IConfigurationManager>();
config.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(new XbmcMetadataOptions());
var nfoConfig = new XbmcMetadataOptions()
{
UserId = "F38E6443-090B-4F7A-BD12-9CFF5020F7BC"
};
var configManager = new Mock<IConfigurationManager>();
configManager.Setup(x => x.GetConfiguration(It.IsAny<string>()))
.Returns(nfoConfig);
var user = new Mock<IUserManager>();
user.Setup(x => x.GetUserById(It.IsAny<Guid>()))
.Returns(_testUser);
var userData = new Mock<IUserDataManager>();
userData.Setup(x => x.GetUserData(_testUser, It.IsAny<BaseItem>()))
.Returns(new UserItemData());
_parser = new MovieNfoParser(new NullLogger<MovieNfoParser>(), config.Object, providerManager.Object, user.Object, userData.Object);
_userDataManager = userData.Object;
_parser = new MovieNfoParser(new NullLogger<MovieNfoParser>(), configManager.Object, providerManager.Object, user.Object, userData.Object);
}
[Fact]
@ -91,6 +108,12 @@ namespace Jellyfin.XbmcMetadata.Tests.Parsers
Assert.Equal("Test Lyricist", lyricist!.Name);
Assert.Equal(new DateTime(2019, 8, 6, 9, 1, 18), item.DateCreated);
// userData
var userData = _userDataManager.GetUserData(_testUser, item);
Assert.Equal(2, userData.PlayCount);
Assert.True(userData.Played);
Assert.Equal(new DateTime(2021, 02, 11, 07, 47, 23), userData.LastPlayedDate);
}
[Fact]

@ -30,6 +30,9 @@
<plot>Fueled by his restored faith in humanity and inspired by Superman&apos;s selfless act, Bruce Wayne enlists the help of his newfound ally, Diana Prince, to face an even greater enemy. Together, Batman and Wonder Woman work quickly to find and recruit a team of meta-humans to stand against this newly awakened threat. But despite the formation of this unprecedented league of heroes-Batman, Wonder Woman, Aquaman, Cyborg and The Flash-it may already be too late to save the planet from an assault of catastrophic proportions.</plot>
<tagline>Justice for all.</tagline>
<runtime>120</runtime>
<playcount>2</playcount>
<watched>true</watched>
<lastplayed>2021-02-11 07:47:23</lastplayed>
<thumb aspect="set.poster" preview="https://assets.fanart.tv/preview/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg">https://assets.fanart.tv/fanart/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg</thumb>
<thumb aspect="set.poster" preview="https://assets.fanart.tv/preview/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg">https://assets.fanart.tv/fanart/movies/468551/movieposter/justice-league-collection-5c24ea65591d3.jpg</thumb>
<thumb aspect="set.clearlogo" preview="https://assets.fanart.tv/preview/movies/468551/hdmovielogo/justice-league-collection-5ba855ed4239a.png">https://assets.fanart.tv/fanart/movies/468551/hdmovielogo/justice-league-collection-5ba855ed4239a.png</thumb>
@ -81,8 +84,6 @@
<thumb preview="https://assets.fanart.tv/preview/movies/141052/moviebackground/justice-league-5a119394ea362.jpg">https://assets.fanart.tv/fanart/movies/141052/moviebackground/justice-league-5a119394ea362.jpg</thumb>
</fanart>
<mpaa>Australia:M</mpaa>
<playcount>0</playcount>
<lastplayed></lastplayed>
<id>tt0974015</id>
<uniqueid type="imdb" default="true">tt0974015</uniqueid>
<genre>Action</genre>

Loading…
Cancel
Save