public void CurrentPath_WithWrongAlternatePath_ReturnsCorrectPath()
 {
     var asset = new JavascriptAsset(_context, _settings) { Path = "original-path" };
     asset.AlternatePaths.Add("test-alt-name2", "test-value");
     Assert.That(asset.CurrentAlternateName, Is.EqualTo("test-alt-name"));
     Assert.That(asset.CurrentPath, Is.EqualTo("original-path"));
 }
 public bool Equals(JavascriptAsset other)
 {
     if (ReferenceEquals(null, other)) {
         return false;
     }
     if (ReferenceEquals(this, other)) {
         return true;
     }
     return Equals(other.Path, Path) && Equals(other.ConditionalEquality, ConditionalEquality) && Equals(other.ConditionalBrowser, ConditionalBrowser);
 }
 public bool Equals(JavascriptAsset other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.Path, Path) && Equals(other.ConditionalEquality, ConditionalEquality) && Equals(other.ConditionalBrowser, ConditionalBrowser));
 }
 public void CurrentPathIsExternal_ExternalPath_ReturnsTrue()
 {
     var asset = new JavascriptAsset(_context, _settings) { Path = "http://original-path" };
     Assert.That(asset.CurrentPath, Is.EqualTo("http://original-path"));
     Assert.That(asset.CurrentPathIsExternal, Is.True);
 }
 public void Setup()
 {
     _cssAsset = new CssAsset(_context, _setitngs);
     _jsAsset = new JavascriptAsset(_context, _setitngs);
 }
        public void JavascriptAsset_DoesNotProcess()
        {
            var reader = GetReader("body { background: url(a/url.png); }");
            var asset = new JavascriptAsset(_context, _settings) { Path = "", IgnoreProcessing = true, Reader = reader };

            var processer = new CssRelativePathProcessor(_urlManager.Object);

            var results = processer.Process(new[] { asset });

            _urlManager.Verify(manager => manager.GetAbsoluteUrl(It.IsAny<string>(), It.IsAny<string>()), Times.Never());
            Assert.That(ReferenceEquals(results.Single().Reader, reader));
            Assert.That(asset.Reader.Content, Is.Not.ContainsSubstring(_fakeAbsoluteUrlPrefix));
        }
        public void JavascriptAsset_GetKey_GetsCorrectExternalFlag()
        {
            var asset = new JavascriptAsset(_context, _notExternalAltSettings) {
                Path = "valid-path"
            };
            asset.AlternatePaths.Add("notExternal", "/relative-path.css");
            asset.AlternatePaths.Add("external", "http://www.fullpath.com/file.css");

            var notExternalKey = asset.Key;
            Assert.That(notExternalKey, Is.Not.Null);
            Assert.That(notExternalKey.IsExternal, Is.False);

            asset = new JavascriptAsset(_context, _externalAltSettings) {
                Path = "valid-path"
            };
            asset.AlternatePaths.Add("notExternal", "/relative-path.css");
            asset.AlternatePaths.Add("external", "http://www.fullpath.com/file.css");

            var externalKey = asset.Key;
            Assert.That(externalKey, Is.Not.Null);
            Assert.That(externalKey.IsExternal, Is.True);
        }
 public void JavascriptAsset_GetKey_ReturnsCssAssetKey()
 {
     var asset = new JavascriptAsset(_context, _settings) {
         Path = "valid-path"
     };
     Assert.That(asset.Key as JavascriptAssetKey, Is.Not.Null);
 }
 public void EqualsOperator_Nulls_AreNotEqual()
 {
     var asset = new JavascriptAsset(_context, _settings);
     Assert.IsFalse(null == asset);
     Assert.IsFalse(asset == null);
 }
 public void JavascriptAsset_GetKey_GetsCorrectBrowser()
 {
     var asset = new JavascriptAsset(_context, _settings) {
         Path = "valid-path",
         ConditionalBrowser = IE.Version.IE7
     };
     var key = asset.Key;
     Assert.That(key, Is.Not.Null);
     Assert.That(key.Browser, Is.EqualTo(IE.Version.IE7));
 }
 public void Equals_AssetWithSameProperties_IsEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) {
         Path = "test-path",
         ConditionalEquality = IE.Equality.GreaterThan,
         ConditionalBrowser = IE.Version.IE5
     };
     var equalAsset = new JavascriptAsset(_context, _settings) {
         Path = "test-path",
         ConditionalEquality = IE.Equality.GreaterThan,
         ConditionalBrowser = IE.Version.IE5
     };
     Assert.IsTrue(asset.Equals(equalAsset));
 }
 public void Equals_AssetWithUnselectedAltPath_IsEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) { ConditionalBrowser = IE.Version.IE5 };
     asset.AlternatePaths.Add("unselected-alt-name", "/other-path.css");
     var equalAsset = new JavascriptAsset(_context, _settings) { ConditionalBrowser = IE.Version.IE5 };
     Assert.IsTrue(asset.Equals(equalAsset));
 }
 public void Equals_AssetWithSameEquality_IsEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) { ConditionalEquality = IE.Equality.GreaterThan };
     var equalAsset = new JavascriptAsset(_context, _settings) { ConditionalEquality = IE.Equality.GreaterThan };
     Assert.IsTrue(asset.Equals(equalAsset));
 }
 public void Equals_AssetWithSamePath_IsEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) { Path = "test-path" };
     var equalAsset = new JavascriptAsset(_context, _settings) { Path = "test-path" };
     Assert.IsTrue(asset.Equals(equalAsset));
 }
 public void Equals_AssetWithSameBrowser_IsEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) { ConditionalBrowser = IE.Version.IE5 };
     var equalAsset = new JavascriptAsset(_context, _settings) { ConditionalBrowser = IE.Version.IE5 };
     Assert.IsTrue(asset.Equals(equalAsset));
 }
 public void Equals_AssetWithDifferentPath_IsNotEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) { Path = "test-path" };
     var equalAsset = new JavascriptAsset(_context, _settings) { Path = "test-path2" };
     Assert.IsFalse(asset.Equals(equalAsset));
 }
 public void Equals_AssetWithDifferentEquality_IsNotEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) { ConditionalEquality = IE.Equality.LessThan };
     var equalAsset = new JavascriptAsset(_context, _settings) { ConditionalEquality = IE.Equality.GreaterThan };
     Assert.IsFalse(asset.Equals(equalAsset));
 }
 public void CurrentPathIsExternal_RelativePath_ReturnsFalse()
 {
     var asset = new JavascriptAsset(_context, _settings) { Path = "original-path" };
     Assert.That(asset.CurrentPath, Is.EqualTo("original-path"));
     Assert.That(asset.CurrentPathIsExternal, Is.False);
 }
 public void Equals_NonJavascriptAsset_IsNotEqual()
 {
     var asset = new JavascriptAsset(_context, _settings);
     Assert.IsFalse(asset.Equals("test"));
 }
 public void Render_NoAlternateName_RendersAlternateFromSettings()
 {
     // if no alternate path name is passed, the path from settings is used.
     Assert.Inconclusive("Not Yet Implemented - Must Mock Settings");
     var newAsset = new JavascriptAsset(_context, _settings) { Path = "test-path" };
     _assetManager.Add(newAsset, "test-group");
     _assetManager.Render(AssetType.Javascript, "test-group");
     Assert.That(_buildHtmlCalls.Count, Is.EqualTo(1));
     var call = _buildHtmlCalls.First();
     //Assert.That(call.AlternateName, Is.EqualTo("an-alt-path"));
 }
 public void Equals_Null_IsNotEqual()
 {
     var asset = new JavascriptAsset(_context, _settings);
     Assert.IsFalse(asset.Equals(null));
 }
 public void Equals_AssetWithDifferentBrowser_IsNotEqual()
 {
     var asset = new JavascriptAsset(_context, _settings) { ConditionalBrowser = IE.Version.IE5 };
     var equalAsset = new JavascriptAsset(_context, _settings) { ConditionalBrowser = IE.Version.IE6 };
     Assert.IsFalse(asset.Equals(equalAsset));
 }
 public void Equals_SameAsset_IsEqual()
 {
     var asset = new JavascriptAsset(_context, _settings);
     Assert.IsTrue(asset.Equals(asset));
 }
 public void JavascriptAsset_GetKey_GetsCorrectEquality()
 {
     var asset = new JavascriptAsset(_context, _settings) {
         Path = "valid-path",
         ConditionalEquality = IE.Equality.GreaterThan
     };
     var key = asset.Key;
     Assert.That(key, Is.Not.Null);
     Assert.That(key.Equality, Is.EqualTo(IE.Equality.GreaterThan));
 }
 public void Render_JavascriptAssetType_RendersOnlyCorrectAssetType()
 {
     // given mixed assets, a render of AssetType.Javascript only returns Javascript assets
     var cssAsset = new CssAsset(_context, _settings) { Path = "test-path" };
     _assetManager.Add(cssAsset, null);
     var jsAsset = new JavascriptAsset(_context, _settings) { Path = "test-path2" };
     _assetManager.Add(jsAsset, null);
     _assetManager.Render(AssetType.Javascript, null);
     Assert.That(_buildHtmlCalls.Count, Is.EqualTo(1));
     var call = _buildHtmlCalls.First();
     Assert.That(call.Assets.Count(), Is.EqualTo(1));
     var asset = call.Assets.First();
     Assert.IsInstanceOf<JavascriptAsset>(asset);
     Assert.That(asset.Path, Is.EqualTo("test-path2"));
 }
 public void JavascriptAsset_GetKey_NonExistantAlternateName_ThrowsNoErrors()
 {
     var asset = new JavascriptAsset(_context, _notExternalAltSettings) {
         Path = "valid-path"
     };
     var key = asset.Key;
     Assert.That(key, Is.Not.Null);
 }
 public void CurrentFilePath_ExternalPath_ReturnsUnmodifiedPath()
 {
     var asset = new JavascriptAsset(_context, _settings) { Path = "http://original-path" };
     Assert.That(asset.CurrentPath, Is.EqualTo("http://original-path"));
     Assert.That(asset.CurrentFilePath, Is.EqualTo(null));
 }
 public void JavascriptAsset_GetKey_ThrowsNoErrors()
 {
     var asset = new JavascriptAsset(_context, _settings) {
                                  Path = "valid-path"
                              };
     Assert.That(asset.Key, Is.Not.Null);
 }
 public void CurrentFilePath_RelativePath_CallsMapPath()
 {
     var asset = new JavascriptAsset(_context, _settings) { Path = "original-path" };
     Assert.That(asset.CurrentPath, Is.EqualTo("original-path"));
     Assert.That(asset.CurrentFilePath.StartsWith(@"c:\full\path\"));
 }
 public void CurrentAlternateName_ReturnsFromSettings()
 {
     var asset = new JavascriptAsset(_context, _settings);
     Assert.That(asset.CurrentAlternateName, Is.EqualTo("test-alt-name"));
 }
        public void FixtureInit()
        {
            var cssConfig = new Mock<AssetConfiguration>();
            cssConfig.Setup(c => c.AlternateName).Returns(String.Empty);
            var jsConfig = new Mock<AssetConfiguration>();
            jsConfig.Setup(c => c.AlternateName).Returns(String.Empty);

            var settings = new Mock<IAssetManagerSettings>();
            settings.Setup(s => s.Css).Returns(cssConfig.Object);
            settings.Setup(s => s.Javascript).Returns(jsConfig.Object);

            _settings = settings.Object;

            var request = new Mock<HttpRequestBase>();
            request.Setup(r => r.MapPath(It.IsAny<string>()))
                .Returns<string>(s => @"c:\full\path\" + s);
            var context = new Mock<HttpContextBase>();
            context.Setup(c => c.Request).Returns(request.Object);

            _context = context.Object;

            _builder = new JavascriptHtmlBuilder();
            _conditionalAsset = new JavascriptAsset(_context, _settings) {
                Path = "~/test-path.css",
                ConditionalBrowser = IE.Version.IE7,
                ConditionalEquality = IE.Equality.LessThan
            };
            _asset = new JavascriptAsset(_context, _settings) {
                Path = "~/test-path2.css",
            };
        }