forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPropertiesHelperTest.cs
46 lines (40 loc) · 1.37 KB
/
PropertiesHelperTest.cs
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
using System.Collections.Generic;
using NHibernate.Util;
using NUnit.Framework;
namespace NHibernate.Test.UtilityTest
{
[TestFixture]
public class PropertiesHelperTest
{
[Test]
public void WhenInvalidBoolValueThenUseDefault()
{
Assert.That(PropertiesHelper.GetBoolean("myProp", new Dictionary<string, string> {{"myProp", "pizza"}}, false), Is.False);
}
[Test]
public void WhenInvalidInt32ValueThenUseDefault()
{
Assert.That(PropertiesHelper.GetInt32("myProp", new Dictionary<string, string> { { "myProp", "pizza" } }, 5), Is.EqualTo(5));
}
[Test]
public void WhenInvalidInt64ValueThenUseDefault()
{
Assert.That(PropertiesHelper.GetInt64("myProp", new Dictionary<string, string> { { "myProp", "pizza" } }, 5), Is.EqualTo(5));
}
[Test]
public void WhenValidBoolValueThenValue()
{
Assert.That(PropertiesHelper.GetBoolean("myProp", new Dictionary<string, string> { { "myProp", "true" } }, false), Is.True);
}
[Test]
public void WhenValidInt32ValueThenValue()
{
Assert.That(PropertiesHelper.GetInt32("myProp", new Dictionary<string, string> { { "myProp", int.MaxValue.ToString() } }, 5), Is.EqualTo(int.MaxValue));
}
[Test]
public void WhenValidInt64ValueThenValue()
{
Assert.That(PropertiesHelper.GetInt64("myProp", new Dictionary<string, string> { { "myProp", long.MaxValue.ToString() } }, 5), Is.EqualTo(long.MaxValue));
}
}
}