forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNullableDictionaryFixture.cs
75 lines (59 loc) · 1.89 KB
/
NullableDictionaryFixture.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
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
using System.Collections.Generic;
using NHibernate.Util;
using NUnit.Framework;
namespace NHibernate.Test.UtilityTest
{
/// <summary>
/// Tests for NullableDictionary.
/// </summary>
[TestFixture]
public class NullableDictionaryFixture
{
private NullableDictionary<string, string> nullableDictionary;
private readonly string _itemKey = "key";
private readonly string _itemValue = "value";
private readonly string _nullItemKey = null;
private readonly string _nullItemValue = "null value";
[SetUp]
public void SetUp()
{
nullableDictionary = new NullableDictionary<string, string>();
}
[Test]
public void AddKeyValue()
{
//non-null key
nullableDictionary.Add(_itemKey, _itemValue);
Assert.AreEqual(1, nullableDictionary.Count);
Assert.AreEqual(nullableDictionary[_itemKey], _itemValue);
//null key
nullableDictionary.Add(_nullItemKey, _nullItemValue);
Assert.AreEqual(2, nullableDictionary.Count);
Assert.AreEqual(nullableDictionary[_nullItemKey], _nullItemValue);
}
[Test]
public void AddUsingIndexer()
{
//non-null key
nullableDictionary[_itemKey] = _itemValue;
Assert.AreEqual(1, nullableDictionary.Count);
Assert.AreEqual(nullableDictionary[_itemKey], _itemValue);
//null key
nullableDictionary[_nullItemKey] = _nullItemValue;
Assert.AreEqual(2, nullableDictionary.Count);
Assert.AreEqual(nullableDictionary[_nullItemKey], _nullItemValue);
}
[Test]
public void AddKeyValuePair()
{
//non-null key
nullableDictionary.Add(new KeyValuePair<string, string>(_itemKey, _itemValue));
Assert.AreEqual(1, nullableDictionary.Count);
Assert.AreEqual(nullableDictionary[_itemKey], _itemValue);
//null key
nullableDictionary.Add(new KeyValuePair<string, string>(_nullItemKey, _nullItemValue));
Assert.AreEqual(2, nullableDictionary.Count);
Assert.AreEqual(nullableDictionary[_nullItemKey], _nullItemValue);
}
}
}