Exemplo n.º 1
0
        public void SetUp()
        {
            var services = new ServiceCollection();
            var mock     = new Mock <IStaticAssetsResolver>();

            mock.Setup(m => m.GetScriptUrl(It.IsAny <string>())).Returns <string>(s => $"script:{s}");
            mock.Setup(m => m.GetStylesheetUrl(It.IsAny <string>())).Returns <string>(s => $"stylesheet:{s}");
            services.AddSingleton(provider => mock.Object);

            ServiceProvider.Setup(services);
        }
Exemplo n.º 2
0
        public void RenderStylesheets_Development()
        {
            var mock = new Mock <IWebHostEnvironment>();

            mock.Setup(m => m.EnvironmentName).Returns("Development");
            ServiceProvider.AddSingleton(provider => mock.Object);

            var context = new DefaultHttpContext();

            context.AddStylesheet("main");

            var rendered = context.RenderStylesheets();

            var expected = new HtmlString("<script src=\"stylesheet:main\"></script>\n");

            Assert.AreEqual(expected.Value, rendered.Value);
        }
Exemplo n.º 3
0
        public void RenderStylesheets_Production()
        {
            var mock = new Mock <IWebHostEnvironment>();

            mock.Setup(m => m.EnvironmentName).Returns("Production");
            ServiceProvider.AddSingleton(provider => mock.Object);

            var context = new DefaultHttpContext();

            context.AddStylesheet("main");

            var rendered = context.RenderStylesheets();

            var expected = new HtmlString("<link rel=\"stylesheet\" href=\"stylesheet:main\"/>\n");

            Assert.AreEqual(expected.Value, rendered.Value);
        }