You've already forked linux-packaging-mono
data
debian
docs
eglib
external
Lucene.Net
Newtonsoft.Json
aspnetwebstack
packages
src
test
Microsoft.TestCommon
Microsoft.Web.Helpers.Test
Microsoft.Web.Http.Data.Test
Microsoft.Web.Mvc.Test
Microsoft.Web.WebPages.OAuth.Test
SPA.Test
System.Json.Test.Integration
System.Json.Test.Unit
System.Net.Http.Formatting.Test.Integration
System.Net.Http.Formatting.Test.Unit
System.Web.Helpers.Test
System.Web.Http.Integration.Test
System.Web.Http.SelfHost.Test
System.Web.Http.Test
System.Web.Http.WebHost.Test
System.Web.Mvc.Test
System.Web.Razor.Test
System.Web.WebPages.Administration.Test
System.Web.WebPages.Deployment.Test
System.Web.WebPages.Razor.Test
System.Web.WebPages.Test
ApplicationParts
Extensions
Helpers
Html
Instrumentation
Mvc
Properties
ScopeStorage
TestFiles
Utils
Validation
WebPage
ApplicationStartPageTest.cs
BrowserHelpersTest.cs
BrowserOverrideStoresTest.cs
BuildManagerExceptionUtilTest.cs
BuildManagerWrapperTest.cs
CookieBrowserOverrideStoreTest.cs
DefaultDisplayModeTest.cs
DisplayInfoTest.cs
DisplayModeProviderTest.cs
DynamicHttpApplicationStateTest.cs
DynamicPageDataDictionaryTest.cs
FileExistenceCacheTest.cs
LayoutTest.cs
PageDataDictionaryTest.cs
RenderPageTest.cs
RequestBrowserOverrideStoreTest.cs
RequestResourceTrackerTest.cs
SectionControlBuilderTest.cs
StartPageTest.cs
TemplateStackTest.cs
UrlDataTest.cs
Utils.cs
VirtualPathFactoryExtensionsTest.cs
VirtualPathFactoryManagerTest.cs
WebPageContextTest.cs
WebPageExecutingBaseTest.cs
WebPageHttpHandlerTest.cs
WebPageHttpModuleTest.cs
WebPageRenderingBaseTest.cs
WebPageRouteTest.cs
WebPageSurrogateControlBuilderTest.cs
WebPageTest.cs
App.config
PreApplicationStartCodeTest.cs
System.Web.WebPages.Test.csproj
packages.config
WebMatrix.Data.Test
WebMatrix.WebData.Test
Settings.StyleCop
tools
.gitattributes
.gitignore
License.txt
README.md
Runtime.msbuild
Runtime.sln
Runtime.xunit
Settings.StyleCop
build.cmd
binary-reference-assemblies
cecil
debian-snapshot
ikdasm
ikvm
referencesource
rx
ikvm-native
libgc
m4
man
mcs
mono
msvc
po
runtime
samples
scripts
support
tools
AUTHORS
COPYING.LIB
ChangeLog.REMOVED.git-id
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
build-mingw32.sh
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-core.spec
mono-core.spec.in
mono-uninstalled.pc.in
test-driver
winconfig.h
142 lines
4.7 KiB
C#
142 lines
4.7 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
|
|
|
using Moq;
|
|
using Xunit;
|
|
|
|
namespace System.Web.WebPages.Test
|
|
{
|
|
public class DefaultDisplayModeTest
|
|
{
|
|
[Fact]
|
|
public void DefaultDisplayModeWithEmptySuffix()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode();
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, "/bar/baz.aspx", virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.Equal(String.Empty, displayMode.DisplayModeId);
|
|
Assert.Equal("/bar/baz.aspx", info.FilePath);
|
|
}
|
|
|
|
[Fact]
|
|
public void DefaultDisplayModeWithNullSuffix()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode(null);
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, "/bar/baz.aspx", virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.Equal(String.Empty, displayMode.DisplayModeId);
|
|
Assert.Equal("/bar/baz.aspx", info.FilePath);
|
|
}
|
|
|
|
[Fact]
|
|
public void DefaultDisplayModeSetSuffixAsId()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act & Assert
|
|
Assert.Equal("foo", displayMode.DisplayModeId);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDisplayInfoWithNullOrEmptySuffixReturnsPathThatExists()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, "/bar/baz.aspx", virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.IsType<DefaultDisplayMode>(info.DisplayMode);
|
|
Assert.Equal("/bar/baz.foo.aspx", info.FilePath);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDisplayInfoInsertsSuffixIntoVirtualPathThatExists()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, "/bar/baz.aspx", virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.IsType<DefaultDisplayMode>(info.DisplayMode);
|
|
Assert.Equal("/bar/baz.foo.aspx", info.FilePath);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDisplayInfoInsertsSuffixBeforeLastSectionOfExtension()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, "/bar/baz.txt.aspx", virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.Equal("/bar/baz.txt.foo.aspx", info.FilePath);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDisplayInfoSuffixesPathWithNoExtension()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, "/bar/baz", virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.Equal("/bar/baz.foo", info.FilePath);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDisplayInfoWithNullVirtualPath()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, virtualPath: null, virtualPathExists: virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.Null(info);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDisplayInfoSuffixesPathWithEmptyVirtualPath()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, String.Empty, virtualPath => true);
|
|
|
|
// Assert
|
|
Assert.Equal(String.Empty, info.FilePath);
|
|
}
|
|
|
|
[Fact]
|
|
public void GetDisplayInfoReturnsNullIfPathDoesNotExist()
|
|
{
|
|
// Arrange
|
|
DefaultDisplayMode displayMode = new DefaultDisplayMode("foo");
|
|
|
|
// Act
|
|
DisplayInfo info = displayMode.GetDisplayInfo(new Mock<HttpContextBase>(MockBehavior.Strict).Object, "/bar/baz", virtualPath => false);
|
|
|
|
// Assert
|
|
Assert.Null(info);
|
|
}
|
|
}
|
|
}
|