forked from andrewdavey/cassette
/
ScriptBundleFactory.cs
75 lines (68 loc) · 2.42 KB
/
ScriptBundleFactory.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
using System.Linq;
using Cassette.IO;
using Should;
using Xunit;
using Cassette.Configuration;
namespace Cassette.Scripts
{
public class ScriptBundleFactory_Tests
{
readonly CassetteSettings settings;
public ScriptBundleFactory_Tests()
{
settings = new CassetteSettings("");
}
[Fact]
public void CreateBundleReturnsScriptBundle()
{
var factory = new ScriptBundleFactory(settings);
var bundle = factory.CreateBundle(
"~/test",
Enumerable.Empty<IFile>(),
new BundleDescriptor { AssetFilenames = { "*" } }
);
bundle.ShouldBeType<ScriptBundle>();
}
[Fact]
public void CreateBundleAssignsScriptBundleDirectory()
{
var factory = new ScriptBundleFactory(settings);
var bundle = factory.CreateBundle(
"~/test",
Enumerable.Empty<IFile>(),
new BundleDescriptor { AssetFilenames = { "*" } }
);
bundle.Path.ShouldEqual("~/test");
}
[Fact]
public void CreateBundleWithUrlCreatesExternalScriptBundle()
{
new ScriptBundleFactory(settings).CreateExternalBundle("http://test.com/api.js").ShouldBeType<ExternalScriptBundle>();
}
[Fact]
public void GivenDescriptorIsFromFile_WhenCreateBundle_ThenBundleIsFromDescriptorFileEqualsTrue()
{
var factory = new ScriptBundleFactory(settings);
var descriptor = new BundleDescriptor
{
IsFromFile = true,
AssetFilenames = { "*" }
};
var bundle = factory.CreateBundle(
"~",
Enumerable.Empty<IFile>(),
descriptor
);
bundle.IsFromDescriptorFile.ShouldBeTrue();
}
[Fact]
public void CreateBundleAssignsSettingsDefaultProcessor()
{
var processor = new ScriptPipeline();
settings.SetDefaultBundleProcessor(processor);
var factory = new ScriptBundleFactory(settings);
var bundle = factory.CreateBundle("~", Enumerable.Empty<IFile>(), new BundleDescriptor { AssetFilenames = { "*" } });
bundle.Processor.ShouldBeSameAs(processor);
}
}
}