public void Make_Bundle_Url() { var hasher = new Mock<IHasher>(); hasher.Setup(x => x.Hash(It.IsAny<string>())).Returns("blah"); var options = new SmidgeOptions { UrlOptions = new UrlManagerOptions { BundleFilePath = "sg" } }; var creator = new DefaultUrlManager( Mock.Of<IOptions<SmidgeOptions>>(x => x.Value == options), Mock.Of<ISmidgeConfig>(x => x.Version == "1"), hasher.Object); var url = creator.GetUrl("my-bundle", ".js"); Assert.Equal("sg/my-bundle.js.v1", url); }
public void Parse_Path() { var path = "c61531b5.2512be3b.bb1214f7.a21bd1fd.js.v1"; var options = new SmidgeOptions { UrlOptions = new UrlManagerOptions { CompositeFilePath = "sg" } }; var manager = new DefaultUrlManager( Mock.Of<IOptions<SmidgeOptions>>(x => x.Value == options), Mock.Of<ISmidgeConfig>(x => x.Version == "1"), Mock.Of<IHasher>()); var result = manager.ParsePath(path); Assert.Equal("1", result.Version); Assert.Equal(4, result.Names.Count()); Assert.Equal(WebFileType.Js, result.WebType); }
public void Make_Composite_Url() { var hasher = new Mock<IHasher>(); hasher.Setup(x => x.Hash(It.IsAny<string>())).Returns((string s) => s.ToLower()); var options = new SmidgeOptions { UrlOptions = new UrlManagerOptions { CompositeFilePath = "sg", MaxUrlLength = 100 } }; var creator = new DefaultUrlManager( Mock.Of<IOptions<SmidgeOptions>>(x => x.Value == options), Mock.Of<ISmidgeConfig>(x => x.Version == "1"), hasher.Object); var url = creator.GetUrls(new List<IWebFile> { new JavaScriptFile("Test1.js"), new JavaScriptFile("Test2.js") }, ".js"); Assert.Equal(1, url.Count()); Assert.Equal("sg/Test1.Test2.js.v1", url.First().Url); Assert.Equal("test1.test2", url.First().Key); }
public void Throws_When_Single_Dependency_Too_Long() { var hasher = new Mock<IHasher>(); hasher.Setup(x => x.Hash(It.IsAny<string>())).Returns((string s) => s.ToLower()); var options = new SmidgeOptions { UrlOptions = new UrlManagerOptions { CompositeFilePath = "sg", MaxUrlLength = 10 } }; var creator = new DefaultUrlManager( Mock.Of<IOptions<SmidgeOptions>>(x => x.Value == options), Mock.Of<ISmidgeConfig>(x => x.Version == "1"), hasher.Object); Assert.Throws<InvalidOperationException>(() => creator.GetUrls(new List<IWebFile> { new JavaScriptFile("Test1.js") }, ".js")); }