-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestEntityResolution.cs
120 lines (98 loc) · 2.92 KB
/
TestEntityResolution.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using MediaBrowser.Library.EntityDiscovery;
using MediaBrowser.Library.Entities;
using TestMediaBrowser.SupportingClasses;
using MediaBrowser.Library.Factories;
using MediaBrowser.Library;
namespace TestMediaBrowser {
[TestFixture]
public class TestEntityResolution {
[Test]
public void TestRecusiveMovieResolution()
{
var resolver = CreateResolver();
var movie = MockFolderMediaLocation.CreateMockLocation(@"
|Rushmore
|part 1
a.avi
|part 2
b.avi
");
Assert.AreEqual(resolver.ResolveType(movie), typeof(Movie));
}
[Test]
public void TestThatUniqueIdChangesWhenTypeChanges() {
var root = MockFolderMediaLocation.CreateMockLocation(@"
|Lib
movie.avi
");
var id = Kernel.Instance.GetItem(root).Id;
Assert.AreEqual(id, Kernel.Instance.GetItem(root).Id);
root = MockFolderMediaLocation.CreateMockLocation(@"
|Lib
movie.avi
movie2.avi
movie3.avi
");
var id2 = Kernel.Instance.GetItem(root).Id;
Assert.AreNotEqual(id, id2);
}
[Test]
public void TestMetadataFoldersShouldBeIgnored() {
var resolver = CreateResolver();
var root = MockFolderMediaLocation.CreateMockLocation(
@"
|TV
|.metaData
metadata.xml
metadata2.xml
|metadata
metadata.xml
metadata2.xml
a.avi
b.avi
c.avi
"
);
BaseItemFactory factory;
IEnumerable<InitializationParameter> setup;
resolver.ResolveEntity(root.Children[0], out factory, out setup);
Assert.IsNull(factory);
resolver.ResolveEntity(root.Children[1], out factory, out setup);
Assert.IsNull(factory);
}
[Test]
public void TestDVDResolution() {
var resolver = CreateResolver();
var root = MockFolderMediaLocation.CreateMockLocation(
@"
|Movies
|Fight Club
|video_ts
movie.vob
|Spandax
movie.vob
");
BaseItemFactory factory;
IEnumerable<InitializationParameter> setup;
resolver.ResolveEntity(root, out factory, out setup);
Assert.AreEqual(typeof(MediaBrowser.Library.Entities.Folder), factory.EntityType);
foreach (var child in root.Children) {
resolver.ResolveEntity(child, out factory, out setup);
Assert.AreEqual(typeof(Movie), factory.EntityType);
Assert.AreEqual(MediaType.DVD, (setup.First() as MediaTypeInitializationParameter).MediaType);
}
}
private static ChainedEntityResolver CreateResolver() {
var resolver = new ChainedEntityResolver() {
new MovieResolver(2, true),
new FolderResolver()
};
return resolver;
}
}
}