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
AntiXsrf
Claims
AntiForgeryConfigTest.cs
AntiForgeryTest.cs
CryptoUtilTest.cs
UnvalidatedRequestValuesTest.cs
Html
Instrumentation
Mvc
Properties
ScopeStorage
TestFiles
Utils
Validation
WebPage
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
81 lines
2.8 KiB
C#
81 lines
2.8 KiB
C#
![]() |
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
|||
|
|
|||
|
using System.Collections.Specialized;
|
|||
|
using System.Web;
|
|||
|
using System.Web.Helpers;
|
|||
|
using Moq;
|
|||
|
using Xunit;
|
|||
|
|
|||
|
namespace Microsoft.WebPages.Test.Helpers
|
|||
|
{
|
|||
|
public class UnvalidatedRequestValuesTest
|
|||
|
{
|
|||
|
[Fact]
|
|||
|
public void Constructor_SetsPropertiesCorrectly()
|
|||
|
{
|
|||
|
// Arrange
|
|||
|
NameValueCollection expectedForm = new NameValueCollection();
|
|||
|
NameValueCollection expectedQueryString = new NameValueCollection();
|
|||
|
|
|||
|
// Act
|
|||
|
UnvalidatedRequestValues unvalidatedValues = new UnvalidatedRequestValues(null, () => expectedForm, () => expectedQueryString);
|
|||
|
|
|||
|
// Assert
|
|||
|
Assert.Same(expectedForm, unvalidatedValues.Form);
|
|||
|
Assert.Same(expectedQueryString, unvalidatedValues.QueryString);
|
|||
|
}
|
|||
|
|
|||
|
[Fact]
|
|||
|
public void Indexer_LooksUpValuesInCorrectOrder()
|
|||
|
{
|
|||
|
// Order should be QueryString, Form, Cookies, ServerVariables
|
|||
|
|
|||
|
// Arrange
|
|||
|
NameValueCollection queryString = new NameValueCollection()
|
|||
|
{
|
|||
|
{ "foo", "fooQueryString" }
|
|||
|
};
|
|||
|
|
|||
|
NameValueCollection form = new NameValueCollection()
|
|||
|
{
|
|||
|
{ "foo", "fooForm" },
|
|||
|
{ "bar", "barForm" },
|
|||
|
};
|
|||
|
|
|||
|
HttpCookieCollection cookies = new HttpCookieCollection()
|
|||
|
{
|
|||
|
new HttpCookie("foo", "fooCookie"),
|
|||
|
new HttpCookie("bar", "barCookie"),
|
|||
|
new HttpCookie("baz", "bazCookie")
|
|||
|
};
|
|||
|
|
|||
|
NameValueCollection serverVars = new NameValueCollection()
|
|||
|
{
|
|||
|
{ "foo", "fooServerVars" },
|
|||
|
{ "bar", "barServerVars" },
|
|||
|
{ "baz", "bazServerVars" },
|
|||
|
{ "quux", "quuxServerVars" },
|
|||
|
};
|
|||
|
Mock<HttpRequestBase> mockRequest = new Mock<HttpRequestBase>();
|
|||
|
mockRequest.Setup(o => o.Cookies).Returns(cookies);
|
|||
|
mockRequest.Setup(o => o.ServerVariables).Returns(serverVars);
|
|||
|
|
|||
|
UnvalidatedRequestValues unvalidatedValues = new UnvalidatedRequestValues(mockRequest.Object, () => form, () => queryString);
|
|||
|
|
|||
|
// Act
|
|||
|
string fooValue = unvalidatedValues["foo"];
|
|||
|
string barValue = unvalidatedValues["bar"];
|
|||
|
string bazValue = unvalidatedValues["baz"];
|
|||
|
string quuxValue = unvalidatedValues["quux"];
|
|||
|
string notFoundValue = unvalidatedValues["not-found"];
|
|||
|
|
|||
|
// Assert
|
|||
|
Assert.Equal("fooQueryString", fooValue);
|
|||
|
Assert.Equal("barForm", barValue);
|
|||
|
Assert.Equal("bazCookie", bazValue);
|
|||
|
Assert.Equal("quuxServerVars", quuxValue);
|
|||
|
Assert.Null(notFoundValue);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|