Ejemplo n.º 1
0
            public void WillCreateJavascriptUrlWithEmtrySignatureGuidWhenContentIsEmpty()
            {
                var testable = new TestableUriBuilder();

                testable.Mock <IRRConfiguration>().Setup(x => x.ContentHost).Returns("http://host");
                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("/vpath");
                var guid    = Guid.NewGuid();
                var content = new byte[0];

                var result = testable.ClassUnderTest.BuildResourceUrl <JavaScriptResource>(guid, content);

                Assert.Equal(string.Format("http://host/vpath/{0}-{1}-{2}", guid.RemoveDashes(), Guid.Empty.RemoveDashes(), new JavaScriptResource().FileName), result);
            }
Ejemplo n.º 2
0
            public void WillCreateCorrectJavaScriptUrlFromString()
            {
                var testable = new TestableUriBuilder();

                testable.Mock <IRRConfiguration>().Setup(x => x.ContentHost).Returns("http://host");
                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("/vpath");
                var guid    = Guid.NewGuid();
                var content = "abc";

                var result = testable.ClassUnderTest.BuildResourceUrl <JavaScriptResource>(guid, content);

                Assert.Equal(string.Format("http://host/vpath/{0}-{1}-{2}", guid.RemoveDashes(), content, new JavaScriptResource().FileName), result);
            }
Ejemplo n.º 3
0
            public void WillCreateCorrectUrl()
            {
                var testable = new TestableUriBuilder();

                testable.Mock <IRRConfiguration>().Setup(x => x.ContentHost).Returns("http://host");
                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("/vpath");
                var guid    = Guid.NewGuid();
                var content = new byte[] { 1 };

                var result = testable.ClassUnderTest.BuildSpriteUrl(guid, content);

                Assert.Equal(result, string.Format("http://host/vpath/{0}-{1}.png", guid.RemoveDashes(), Hasher.Hash(content).RemoveDashes()));
            }
Ejemplo n.º 4
0
            public void WillThrowArgumentExceptionIfResourceTypeIsUnknown()
            {
                var testable = new TestableUriBuilder();

                testable.Mock <IRRConfiguration>().Setup(x => x.ContentHost).Returns("http://host");
                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("/vpath");
                var guid    = Guid.NewGuid();
                var content = "abc";

                var result = Record.Exception(() => testable.ClassUnderTest.BuildResourceUrl(guid, content, typeof(Object))) as ArgumentException;

                Assert.NotNull(result);
            }
Ejemplo n.º 5
0
            public void WillCreateCorrectCssUrl()
            {
                var testable = new TestableUriBuilder();

                testable.Mock <IRRConfiguration>().Setup(x => x.ContentHost).Returns("http://host");
                testable.Mock <IRRConfiguration>().Setup(x => x.ResourceAbsolutePath).Returns("/vpath");
                var guid    = Guid.NewGuid();
                var content = new byte[] { 1 };

                var result = testable.ClassUnderTest.BuildResourceUrl <CssResource>(guid, content);

                Assert.Equal(string.Format("http://host/vpath/{0}-{1}-{2}", guid.RemoveDashes(), Hasher.Hash(content).RemoveDashes(), new CssResource().FileName), result);
            }
Ejemplo n.º 6
0
            public void WillTransformUrlIfTransformerExists()
            {
                var testable = new TestableUriBuilder();

                Registry.UrlTransformer = (c, x, y) =>
                {
                    var newUrlHost = new Uri(y).Host;
                    return(y.Replace(newUrlHost, "funny." + newUrlHost));
                };
                testable.Mock <IRRConfiguration>().Setup(x => x.ContentHost).Returns("http://host");
                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("/vpath");
                var guid    = Guid.NewGuid();
                var content = new byte[] { 1 };

                var result = testable.ClassUnderTest.BuildSpriteUrl(guid, content);

                Assert.Equal(result, string.Format("http://funny.host/vpath/{0}-{1}.png", guid.RemoveDashes(), Hasher.Hash(content).RemoveDashes()));
                Registry.UrlTransformer = null;
            }
Ejemplo n.º 7
0
            public void WillTransformUrlIfTransformerExists()
            {
                var testable = new TestableUriBuilder();

                Registry.UrlTransformer = (c, x, y) =>
                {
                    var newUrlHost = new Uri(y).Host;
                    return(y.Replace(newUrlHost, "funny." + newUrlHost));
                };
                testable.Mock <IRRConfiguration>().Setup(x => x.ContentHost).Returns("http://host");
                testable.Mock <IRRConfiguration>().Setup(x => x.SpriteVirtualPath).Returns("/vpath");
                var guid    = Guid.NewGuid();
                var content = "abc";

                var result = testable.ClassUnderTest.BuildResourceUrl <CssResource>(guid, content);

                Assert.Equal(string.Format("http://funny.host/vpath/{0}-{1}-{2}", guid.RemoveDashes(), content, new CssResource().FileName), result);
                Registry.UrlTransformer = null;
            }