Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/aspnetwebstack.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/Microsoft.Web.Mvc.Test/Test/ElementalValueProviderTest.cs')
-rw-r--r--test/Microsoft.Web.Mvc.Test/Test/ElementalValueProviderTest.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/Microsoft.Web.Mvc.Test/Test/ElementalValueProviderTest.cs b/test/Microsoft.Web.Mvc.Test/Test/ElementalValueProviderTest.cs
new file mode 100644
index 00000000..5179f515
--- /dev/null
+++ b/test/Microsoft.Web.Mvc.Test/Test/ElementalValueProviderTest.cs
@@ -0,0 +1,54 @@
+using System;
+using System.Globalization;
+using System.Web.Mvc;
+using Xunit;
+
+namespace Microsoft.Web.Mvc.Test
+{
+ public class ElementalValueProviderTest
+ {
+ [Fact]
+ public void ContainsPrefix()
+ {
+ // Arrange
+ ElementalValueProvider valueProvider = new ElementalValueProvider("foo", 42, null);
+
+ // Act & assert
+ Assert.True(valueProvider.ContainsPrefix("foo"));
+ Assert.False(valueProvider.ContainsPrefix("bar"));
+ }
+
+ [Fact]
+ public void GetValue_NameDoesNotMatch_ReturnsNull()
+ {
+ // Arrange
+ CultureInfo culture = CultureInfo.GetCultureInfo("fr-FR");
+ DateTime rawValue = new DateTime(2001, 1, 2);
+ ElementalValueProvider valueProvider = new ElementalValueProvider("foo", rawValue, culture);
+
+ // Act
+ ValueProviderResult vpResult = valueProvider.GetValue("bar");
+
+ // Assert
+ Assert.Null(vpResult);
+ }
+
+ [Fact]
+ public void GetValue_NameMatches_ReturnsValueProviderResult()
+ {
+ // Arrange
+ CultureInfo culture = CultureInfo.GetCultureInfo("fr-FR");
+ DateTime rawValue = new DateTime(2001, 1, 2);
+ ElementalValueProvider valueProvider = new ElementalValueProvider("foo", rawValue, culture);
+
+ // Act
+ ValueProviderResult vpResult = valueProvider.GetValue("FOO");
+
+ // Assert
+ Assert.NotNull(vpResult);
+ Assert.Equal(rawValue, vpResult.RawValue);
+ Assert.Equal("02/01/2001 00:00:00", vpResult.AttemptedValue);
+ Assert.Equal(culture, vpResult.Culture);
+ }
+ }
+}