1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
// 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"));
}
}
}
|