Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

92 lines
2.6 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using Xunit;
namespace System.Web.Mvc.Test
{
public class ValueProviderUtilTest
{
[Fact]
public void CollectionContainsPrefix_EmptyCollectionReturnsFalse()
{
// Arrange
string[] collection = new string[0];
// Act
bool retVal = ValueProviderUtil.CollectionContainsPrefix(collection, "");
// Assert
Assert.False(retVal);
}
[Fact]
public void CollectionContainsPrefix_ExactMatch()
{
// Arrange
string[] collection = new string[] { "Hello" };
// Act
bool retVal = ValueProviderUtil.CollectionContainsPrefix(collection, "Hello");
// Assert
Assert.True(retVal);
}
[Fact]
public void CollectionContainsPrefix_MatchIsCaseInsensitive()
{
// Arrange
string[] collection = new string[] { "Hello" };
// Act
bool retVal = ValueProviderUtil.CollectionContainsPrefix(collection, "hello");
// Assert
Assert.True(retVal);
}
[Fact]
public void CollectionContainsPrefix_MatchIsNotSimpleSubstringMatch()
{
// Arrange
string[] collection = new string[] { "Hello" };
// Act
bool retVal = ValueProviderUtil.CollectionContainsPrefix(collection, "He");
// Assert
Assert.False(retVal);
}
[Fact]
public void CollectionContainsPrefix_NonEmptyCollectionReturnsTrueIfPrefixIsEmptyString()
{
// Arrange
string[] collection = new string[] { "Hello" };
// Act
bool retVal = ValueProviderUtil.CollectionContainsPrefix(collection, "");
// Assert
Assert.True(retVal);
}
[Fact]
public void CollectionContainsPrefix_PrefixBoundaries()
{
// Arrange
string[] collection = new string[] { "Hello.There[0]" };
// Act
bool retVal1 = ValueProviderUtil.CollectionContainsPrefix(collection, "hello");
bool retVal2 = ValueProviderUtil.CollectionContainsPrefix(collection, "hello.there");
// Assert
Assert.True(retVal1);
Assert.True(retVal2);
Assert.True(ValueProviderUtil.CollectionContainsPrefix(collection, "hello.there[0]"));
Assert.False(ValueProviderUtil.CollectionContainsPrefix(collection, "hello.there.0"));
}
}
}