forked from DotNet4Neo4j/Neo4jClient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndexEntryTests.cs
94 lines (82 loc) · 3.04 KB
/
IndexEntryTests.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace Neo4jClient.Tests
{
public class IndexEntryTests : IClassFixture<CultureInfoSetupFixture>
{
[Fact]
public void CanInitializeWithLongForm()
{
var entry = new IndexEntry
{
Name = "index-entry",
KeyValues = new[]
{
new KeyValuePair<string, object>("foo", 123),
new KeyValuePair<string, object>("bar", "baz")
}
};
Assert.Equal("index-entry", entry.Name);
Assert.Equal(2, entry.KeyValues.Count());
Assert.Equal("foo", entry.KeyValues.ElementAt(0).Key);
Assert.Equal(123, entry.KeyValues.ElementAt(0).Value);
Assert.Equal("bar", entry.KeyValues.ElementAt(1).Key);
Assert.Equal("baz", entry.KeyValues.ElementAt(1).Value);
}
[Fact]
public void CanInitializeWithCollectionIntializer()
{
var entry = new IndexEntry("index-entry")
{
{ "foo", 123 },
{ "bar", "baz" }
};
Assert.Equal("index-entry", entry.Name);
Assert.Equal(2, entry.KeyValues.Count());
Assert.Equal("foo", entry.KeyValues.ElementAt(0).Key);
Assert.Equal(123, entry.KeyValues.ElementAt(0).Value);
Assert.Equal("bar", entry.KeyValues.ElementAt(1).Key);
Assert.Equal("baz", entry.KeyValues.ElementAt(1).Value);
}
[Fact]
public void CanCallAddAfterUsingNameConstructor()
{
// ReSharper disable UseObjectOrCollectionInitializer
var entry = new IndexEntry("index-entry");
entry.Add("qak", "qoo");
// ReSharper restore UseObjectOrCollectionInitializer
Assert.Equal(1, entry.KeyValues.Count());
Assert.Equal("qak", entry.KeyValues.ElementAt(0).Key);
Assert.Equal("qoo", entry.KeyValues.ElementAt(0).Value);
}
[Fact]
public void CanCallAddAfterUsingCollectionIntializer()
{
// ReSharper disable UseObjectOrCollectionInitializer
var entry = new IndexEntry("index-entry")
{
{ "foo", 123 },
{ "bar", "baz" }
};
// ReSharper restore UseObjectOrCollectionInitializer
entry.Add("qak", "qoo");
Assert.Equal(3, entry.KeyValues.Count());
Assert.Equal("qak", entry.KeyValues.ElementAt(2).Key);
Assert.Equal("qoo", entry.KeyValues.ElementAt(2).Value);
}
[Fact]
public void AddAfterAssigningCustomListShouldThrowException()
{
var entry = new IndexEntry
{
KeyValues = new[]
{
new KeyValuePair<string, object>("foo", 123)
}
};
Assert.Throws<InvalidOperationException>(() => entry.Add("qak", "qoo"));
}
}
}