You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
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
AspNetRequestScopeStorageProviderTest.cs
ScopeStorageDictionaryTest.cs
ScopeStorageKeyComparerTest.cs
WebConfigScopeStorageTest.cs
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
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
ikdasm
ikvm
linker
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
ikvm-native
libgc
llvm
m4
man
mcs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
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-uninstalled.pc.in
test-driver
winconfig.h
173 lines
5.0 KiB
C#
173 lines
5.0 KiB
C#
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
|
|
|
|
using System.Collections.Generic;
|
|
using System.Web.WebPages.Scope;
|
|
using Xunit;
|
|
|
|
namespace System.Web.WebPages.Test
|
|
{
|
|
public class ScopeStorageDictionaryTest
|
|
{
|
|
[Fact]
|
|
public void ScopeStorageDictionaryLooksUpLocalValuesFirst()
|
|
{
|
|
// Arrange
|
|
var stateStorage = GetChainedStorageStateDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.Equal(stateStorage["f"], "f2");
|
|
}
|
|
|
|
[Fact]
|
|
public void ScopeStorageDictionaryOverridesParentValuesWithLocalValues()
|
|
{
|
|
// Arrange
|
|
var stateStorage = GetChainedStorageStateDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.Equal(stateStorage["a"], "a2");
|
|
Assert.Equal(stateStorage["d"], "d2");
|
|
}
|
|
|
|
[Fact]
|
|
public void ScopeStorageDictionaryLooksUpParentValuesWhenNotFoundLocally()
|
|
{
|
|
// Arrange
|
|
var stateStorage = GetChainedStorageStateDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.Equal(stateStorage["c"], "c0");
|
|
Assert.Equal(stateStorage["b"], "b1");
|
|
}
|
|
|
|
[Fact]
|
|
public void ScopeStorageDictionaryTreatsNullAsOrdinaryValues()
|
|
{
|
|
// Arrange
|
|
var stateStorage = GetChainedStorageStateDictionary();
|
|
stateStorage["b"] = null;
|
|
|
|
// Act and Assert
|
|
Assert.Null(stateStorage["b"]);
|
|
}
|
|
|
|
[Fact]
|
|
public void ContainsKeyReturnsTrueIfItContainsKey()
|
|
{
|
|
// Arrange
|
|
var scopeStorage = GetChainedStorageStateDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.True(scopeStorage.ContainsKey("f"));
|
|
}
|
|
|
|
[Fact]
|
|
public void ContainsKeyReturnsTrueIfBaseContainsKey()
|
|
{
|
|
// Arrange
|
|
var scopeStorage = GetChainedStorageStateDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.True(scopeStorage.ContainsKey("e"));
|
|
}
|
|
|
|
[Fact]
|
|
public void ContainsKeyReturnsFalseIfItDoesNotContainKeyAndBaseIsNull()
|
|
{
|
|
// Arrange
|
|
var scopeStorage = new ScopeStorageDictionary() { { "foo", "bar" } };
|
|
|
|
// Act and Assert
|
|
Assert.False(scopeStorage.ContainsKey("baz"));
|
|
}
|
|
|
|
[Fact]
|
|
public void CountReturnsCountFromCurrentAndBaseScope()
|
|
{
|
|
// Arrange
|
|
var scopeStorage = GetChainedStorageStateDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.Equal(6, scopeStorage.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void ScopeStorageDictionaryGetsValuesFromCurrentAndBaseScope()
|
|
{
|
|
// Arrange
|
|
var scopeStorage = GetChainedStorageStateDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.Equal(scopeStorage["a"], "a2");
|
|
Assert.Equal(scopeStorage["b"], "b1");
|
|
Assert.Equal(scopeStorage["c"], "c0");
|
|
Assert.Equal(scopeStorage["d"], "d2");
|
|
Assert.Equal(scopeStorage["e"], "e1");
|
|
Assert.Equal(scopeStorage["f"], "f2");
|
|
}
|
|
|
|
[Fact]
|
|
public void ClearRemovesAllItemsFromCurrentScope()
|
|
{
|
|
// Arrange
|
|
var dictionary = new ScopeStorageDictionary { { "foo", "bar" }, { "foo2", "bar2" } };
|
|
|
|
// Act
|
|
dictionary.Clear();
|
|
|
|
// Assert
|
|
Assert.Equal(0, dictionary.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void ScopeStorageDictionaryIsNotReadOnly()
|
|
{
|
|
// Arrange
|
|
var dictionary = new ScopeStorageDictionary();
|
|
|
|
// Act and Assert
|
|
Assert.False(dictionary.IsReadOnly);
|
|
}
|
|
|
|
[Fact]
|
|
public void CopyToCopiesItemsToArrayAtSpecifiedIndex()
|
|
{
|
|
// Arrange
|
|
var dictionary = GetChainedStorageStateDictionary();
|
|
var array = new KeyValuePair<object, object>[8];
|
|
|
|
// Act
|
|
dictionary.CopyTo(array, 2);
|
|
|
|
// Assert
|
|
Assert.Equal(array[2].Key, "a");
|
|
Assert.Equal(array[2].Value, "a2");
|
|
Assert.Equal(array[4].Key, "f");
|
|
Assert.Equal(array[4].Value, "f2");
|
|
Assert.Equal(array[7].Key, "c");
|
|
Assert.Equal(array[7].Value, "c0");
|
|
}
|
|
|
|
private ScopeStorageDictionary GetChainedStorageStateDictionary()
|
|
{
|
|
var root = new ScopeStorageDictionary();
|
|
root["a"] = "a0";
|
|
root["b"] = "b0";
|
|
root["c"] = "c0";
|
|
|
|
var firstGen = new ScopeStorageDictionary(baseScope: root);
|
|
firstGen["a"] = "a1";
|
|
firstGen["b"] = "b1";
|
|
firstGen["d"] = "d1";
|
|
firstGen["e"] = "e1";
|
|
|
|
var secondGen = new ScopeStorageDictionary(baseScope: firstGen);
|
|
secondGen["a"] = "a2";
|
|
secondGen["d"] = "d2";
|
|
secondGen["f"] = "f2";
|
|
|
|
return secondGen;
|
|
}
|
|
}
|
|
}
|