Пример #1
0
        public void WillThrowAnExceptionIfNoHostFoundOrDefaultThemeDataProvided()
        {
            subOptions.Value.Returns(new ThemeOptions <HostTheme>());
            var fakeContext = new DefaultHttpContext();

            fakeContext.Request.Host = new HostString("cabbages.com");
            subContext.HttpContext.Returns(fakeContext);

            var objUt = new HostThemeManager(subOptions, subContext);

            Assert.Throws <InvalidOperationException>(() => objUt.GetThemeKey());
        }
Пример #2
0
        public void WillGetADefaultThemeIfNoHostFound()
        {
            subOptions.Value.Returns(BuildOptions());
            var fakeContext = new DefaultHttpContext();

            fakeContext.Request.Host = new HostString("cabbages.com");
            subContext.HttpContext.Returns(fakeContext);

            var objUt  = new HostThemeManager(subOptions, subContext);
            var result = objUt.GetThemeKey();

            Assert.Equal("End", result);
        }
Пример #3
0
        public void CanGetAThemeFromAHost(string expectedKey, string host, int?port = null)
        {
            subOptions.Value.Returns(BuildOptions());
            var fakeContext = new DefaultHttpContext();

            fakeContext.Request.Host = port.HasValue ? new HostString(host, port.Value) : new HostString(host);
            subContext.HttpContext.Returns(fakeContext);

            var objUt  = new HostThemeManager(subOptions, subContext);
            var result = objUt.GetThemeKey();

            Assert.Equal(expectedKey, result);
        }