public void SessionIsCalledWithBookmarks() { // Arrange var bookmarks = new List <string> { "Bookmark1", "Bookmark2" }; var cypherQuery = new CypherQuery("RETURN 1", new Dictionary <string, object>(), CypherResultMode.Projection, CypherResultFormat.Transactional) { Bookmarks = bookmarks }; using (var testHarness = new BoltTestHarness()) { try { testHarness.CreateAndConnectBoltGraphClient().ExecuteGetCypherResults <object>(cypherQuery).ToArray(); } catch { /*Not interested in actually getting results*/ } //Assert testHarness.MockDriver.Verify(d => d.Session(It.IsAny <AccessMode>(), It.Is <IEnumerable <string> >(s => s.Contains(bookmarks[0]) && s.Contains(bookmarks[1]))), Times.Once); } }
public async Task ArgsContainIdentifier() { const string identifier = "identifier"; const string queryText = "RETURN [] AS data"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Set, CypherResultFormat.Transactional, "neo4j") { Identifier = identifier }; using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock.Setup(r => r["data"]).Returns(new List <INode>()); recordMock.Setup(r => r.Keys).Returns(new[] { "data" }); var testStatementResult = new TestStatementResult(new[] { "data" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); graphClient.OperationCompleted += (s, e) => { e.Identifier.Should().Be(identifier); }; await graphClient.ExecuteGetCypherResultsAsync <IEnumerable <ObjectWithIds> >(cypherQuery); } }
public async Task EmptyCollectionShouldDeserializeCorrectly() { const string queryText = "RETURN [] AS data"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Set, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["data"]) .Returns(new List <INode>() { }); recordMock .Setup(r => r.Keys) .Returns(new[] { "data" }); var testStatementResult = new TestStatementResult(new[] { "data" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var results = (await graphClient.ExecuteGetCypherResultsAsync <IEnumerable <ObjectWithIds> >(cypherQuery)).ToArray(); results.Should().BeEmpty(); } }
public void ArgsContainBookmarksUsed() { // Arrange var bookmarks = new List <string> { "Bookmark1", "Bookmark2" }; const string queryText = "RETURN [] AS data"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Set, CypherResultFormat.Transactional) { Bookmarks = bookmarks }; using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock.Setup(r => r["data"]).Returns(new List <INode>()); recordMock.Setup(r => r.Keys).Returns(new[] { "data" }); var testStatementResult = new TestStatementResult(new[] { "data" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = testHarness.CreateAndConnectBoltGraphClient(); graphClient.OperationCompleted += (s, e) => { e.BookmarksUsed.Should().Contain(bookmarks[0]); e.BookmarksUsed.Should().Contain(bookmarks[1]); }; graphClient.ExecuteGetCypherResults <IEnumerable <ObjectWithIds> >(cypherQuery); } }
public void ArgsContainLastBookmark() { const string lastBookmark = "LastBookmark"; const string queryText = "RETURN [] AS data"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Set, CypherResultFormat.Transactional); using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock.Setup(r => r["data"]).Returns(new List <INode>()); recordMock.Setup(r => r.Keys).Returns(new[] { "data" }); testHarness.MockSession.Setup(s => s.LastBookmark).Returns(lastBookmark); var testStatementResult = new TestStatementResult(new[] { "data" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = testHarness.CreateAndConnectBoltGraphClient(); graphClient.OperationCompleted += (s, e) => { e.LastBookmark.Should().Be(lastBookmark); }; graphClient.ExecuteGetCypherResults <IEnumerable <ObjectWithIds> >(cypherQuery); } }
public async Task SessionIsCalledWithBookmarks() { // Arrange var bookmarks = new List <Bookmark> { Bookmark.From("Bookmark1"), Bookmark.From("Bookmark2") }; var cypherQuery = new CypherQuery("RETURN 1", new Dictionary <string, object>(), CypherResultMode.Projection, CypherResultFormat.Transactional, "neo4j") { Bookmarks = bookmarks }; using (var testHarness = new BoltTestHarness()) { try { (await(await testHarness.CreateAndConnectBoltGraphClient()).ExecuteGetCypherResultsAsync <object>(cypherQuery)).ToArray(); } catch { /*Not interested in actually getting results*/ } //Assert // testHarness.MockDriver.Verify(d => d.Session(It.IsAny<AccessMode>(), It.Is<IEnumerable<string>>(s => s.Contains(bookmarks[0]) && s.Contains(bookmarks[1]))), Times.Once); testHarness.MockDriver.Verify(d => d.AsyncSession(It.IsAny <Action <SessionConfigBuilder> >()), Times.Once); throw new NotImplementedException(); } }
public async Task ShouldBeAbleToCastToObject_WhenUsingReturnAs() { const string queryText = "MATCH (user)-[:hasPost]->(post:Post) WHERE(user.Username = '******') RETURN user{.Username} AS User, post AS Post"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Projection, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { const string username = "******"; const string postName = "Post1"; var user = new Dictionary <string, object> { { "Username", username } }; var postNodeMock = new Mock <INode>(); postNodeMock.Setup(n => n.Id).Returns(1); postNodeMock.Setup(n => n.Properties) .Returns(new Dictionary <string, object> { { "Content", postName } }); var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["User"]) .Returns(user); recordMock .Setup(r => r["Post"]) .Returns(postNodeMock.Object); recordMock .Setup(r => r.Keys) .Returns(new[] { "User", "Post" }); recordMock.Setup(r => r.Values) .Returns(new Dictionary <string, object> { { "User", user }, { "Post", postNodeMock.Object } }); var testStatementResult = new TestStatementResult(new[] { "User", "Post" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var results = (await graphClient.ExecuteGetCypherResultsAsync <PostAndUser>(cypherQuery)).ToArray(); // //Assert var deserializedObject = results.First(); deserializedObject.User.Should().NotBeNull(); deserializedObject.User.Username.Should().Be(username); } }
public async Task CollectionShouldDeserializeCorrectly() { // simulate a collect() const string queryText = "MATCH (start:Node) RETURN collect(start) AS data"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Set, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { var nodeMock = new Mock <INode>(); nodeMock .Setup(n => n.Id) .Returns(1); nodeMock .Setup(n => n.Properties) .Returns(new Dictionary <string, object>() { { "Ids", new List <int> { 1, 2, 3 } } }); var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["data"]) .Returns(new List <INode>() { nodeMock.Object }); recordMock .Setup(r => r.Keys) .Returns(new[] { "data" }); var testStatementResult = new TestStatementResult(new[] { "data" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var results = (await graphClient.ExecuteGetCypherResultsAsync <IEnumerable <ObjectWithIds> >(cypherQuery)).ToArray(); //Assert var deserializedObject = results.First().First(); deserializedObject.Ids.Count.Should().Be(3); deserializedObject.Ids[0].Should().Be(1); deserializedObject.Ids[1].Should().Be(2); deserializedObject.Ids[2].Should().Be(3); } }
public async Task RelationshipShouldDeserializeInDefinedType() { // Arrange const string queryText = "MATCH (n:Test)-[r]->(t:Test) RETURN r AS Rel"; var cypherQuery = new CypherQuery(queryText, new Dictionary <string, object>(), CypherResultMode.Projection, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { var relationshipMock = new Mock <IRelationship>(); relationshipMock .Setup(r => r.StartNodeId) .Returns(1); relationshipMock .Setup(r => r.EndNodeId) .Returns(2); relationshipMock .Setup(r => r.Type) .Returns("Xx"); relationshipMock .Setup(r => r.Id) .Returns(3); relationshipMock .Setup(r => r.Properties) .Returns(new Dictionary <string, object>() { { "Id", 42 } }); var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["Rel"]) .Returns(relationshipMock.Object); recordMock .Setup(r => r.Keys) .Returns(new[] { "Rel" }); var testStatementResult = new TestStatementResult(new[] { "Rel" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var results = (await graphClient.ExecuteGetCypherResultsAsync <RelationGrouper>(cypherQuery)).ToArray(); //Assert results.Length.Should().Be(1); var relation = results.First().Rel; relation.Id.Should().Be(42); } }
public async Task ShouldDeserializePathsResultAsSetBased() { // Arrange const string queryText = @"MATCH (start:Node {Id:$p0}),(end:Node {Id: $p1}), p = shortestPath((start)-[*..5]->(end)) RETURN p"; var parameters = new Dictionary <string, object> { { "p0", 215 }, { "p1", 219 } }; var cypherQuery = new CypherQuery(queryText, parameters, CypherResultMode.Set, CypherResultFormat.Rest, "neo4j"); using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["p"]) .Returns(new TestPath { End = new TestNode { Id = 1 }, Start = new TestNode { Id = 2 }, Relationships = new List <IRelationship> { new TestRelationship() }, Nodes = new List <INode> { new TestNode(), new TestNode() } }); recordMock .Setup(r => r.Keys) .Returns(new[] { "p" }); var testStatementResult = new TestStatementResult(new[] { "p" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var results = (await graphClient.ExecuteGetCypherResultsAsync <PathsResultBolt>(cypherQuery)).ToArray(); //Assert Assert.IsAssignableFrom <IEnumerable <PathsResultBolt> >(results); Assert.Equal(1, results.First().Length); results.First().Nodes.Count().Should().Be(2); results.First().Relationships.Count().Should().Be(1); results.First().End.Id.Should().Be(1); results.First().Start.Id.Should().Be(2); } }
public void TransactionIsCalledWithBookmarks() { // Arrange var bookmarks = new List <string> { "Bookmark1", "Bookmark2" }; using (var testHarness = new BoltTestHarness()) { var gc = testHarness.CreateAndConnectBoltGraphClient() as ITransactionalGraphClient; gc.BeginTransaction(bookmarks); //Assert testHarness.MockDriver.Verify(d => d.Session(It.Is <IEnumerable <string> >(s => s.Contains(bookmarks[0]) && s.Contains(bookmarks[1]))), Times.Once); } }
public async Task ShouldDeserializeCollectionsWithAnonymousReturn() { // Arrange const string queryText = @"MATCH (start:Node) RETURN [start.Id, start.Id] AS Ids"; var cypherQuery = new CypherQuery(queryText, new Dictionary <string, object>(), CypherResultMode.Projection, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["Ids"]) .Returns(new[] { 1, 2, 3 }); recordMock .Setup(r => r.Keys) .Returns(new[] { "Ids" }); var testStatementResult = new TestStatementResult(new[] { "Ids" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); //Session mock??? var dummy = new { Ids = new List <int>() }; var anonType = dummy.GetType(); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var genericGetCypherResults = typeof(IRawGraphClient).GetMethod(nameof(graphClient.ExecuteGetCypherResultsAsync)); var anonymousGetCypherResults = genericGetCypherResults.MakeGenericMethod(anonType); var genericResultsTask = anonymousGetCypherResults.Invoke(graphClient, new object[] { cypherQuery }); await(Task) genericResultsTask; var genericResults = (IEnumerable)((dynamic)genericResultsTask).Result; var results = genericResults.Cast <object>().ToArray(); //Assert Assert.Equal(1, results.Length); var ids = (List <int>)anonType.GetProperty(nameof(dummy.Ids)).GetValue(results.First(), null); ids.Count.Should().Be(3); ids[0].Should().Be(1); ids[1].Should().Be(2); ids[2].Should().Be(3); } }
public async Task CreateWithArrayParametersShouldSerializeAndDeserializeOnReturn() { // Arrange const string queryText = "CREATE (start:Node {obj}) RETURN start"; var testNode = new ObjectWithIds() { Ids = new List <int>() { 1, 2, 3 } }; var queryParams = new Dictionary <string, object>() { { "obj", testNode } }; var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Set, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["start"]) .Returns(testNode); recordMock .Setup(r => r.Keys) .Returns(new[] { "start" }); var testStatementResult = new TestStatementResult(new[] { "start" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var results = (await graphClient.ExecuteGetCypherResultsAsync <ObjectWithIds>(cypherQuery)).ToArray(); //Assert Assert.IsAssignableFrom <IEnumerable <ObjectWithIds> >(results); results.First().Ids.Count.Should().Be(3); results.First().Ids[0].Should().Be(1); results.First().Ids[1].Should().Be(2); results.First().Ids[2].Should().Be(3); } }
public async Task SimpleTransaction_AsTransactionalGc_1Query_Moq() { using (var harness = new BoltTestHarness()) { var graphClient = await harness.CreateAndConnectBoltGraphClient(); var txGc = (ITransactionalGraphClient)graphClient; using (var tx = txGc.BeginTransaction()) { var query = txGc.Cypher.Match("(n)").Set("n.Value = 'test'"); await query.ExecuteWithoutResultsAsync(); await tx.CommitAsync(); } harness.MockDriver.Verify(md => md.AsyncSession(It.IsAny <Action <SessionConfigBuilder> >()), Times.Exactly(1)); } }
public async Task ArgsContainBookmarksUsed() { // Arrange var bookmarks = new List <Bookmark> { Bookmark.From("Bookmark1"), Bookmark.From("Bookmark2") }; const string queryText = "RETURN [] AS data"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Set, CypherResultFormat.Transactional, "neo4j") { Bookmarks = bookmarks }; using (var testHarness = new BoltTestHarness()) { var recordMock = new Mock <IRecord>(); recordMock.Setup(r => r["data"]).Returns(new List <INode>()); recordMock.Setup(r => r.Keys).Returns(new[] { "data" }); var testStatementResult = new TestStatementResult(new[] { "data" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); graphClient.OperationCompleted += (s, e) => { e.BookmarksUsed.Should().Contain(bookmarks[0]); e.BookmarksUsed.Should().Contain(bookmarks[1]); }; var driverSess = testHarness.MockDriver.Object.AsyncSession(); testHarness.MockDriver.Verify(s => s.AsyncSession(), Times.Once); driverSess.Should().NotBeNull(); await graphClient.ExecuteGetCypherResultsAsync <IEnumerable <ObjectWithIds> >(cypherQuery); } }
public async Task ShouldDeserializeMapWithAnonymousReturn() { // simulates the following query const string queryText = "MATCH (start:Node) WITH {Node: start, Count: 1} AS Node, start RETURN Node, start"; var cypherQuery = new CypherQuery(queryText, new Dictionary <string, object>(), CypherResultMode.Projection, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { INode start = new TestNode { Id = 1337, Properties = new Dictionary <string, object>() { { "Ids", new List <int>() { 1, 2, 3 } } } }; IDictionary <string, object> resultMap = new Dictionary <string, object>() { { "Node", start }, { "Count", 1 } }; var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["Node"]) .Returns(resultMap); recordMock .Setup(r => r["Start"]) .Returns(start); recordMock .Setup(r => r.Keys) .Returns(new[] { "Node", "Start" }); var testStatementResult = new TestStatementResult(new[] { "Node", "Start" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); // the anon type var dummy = new { Node = new ObjectWithNodeWithIds(), Start = new ObjectWithIds() }; var anonType = dummy.GetType(); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var genericGetCypherResults = typeof(IRawGraphClient).GetMethod(nameof(graphClient.ExecuteGetCypherResultsAsync)); var anonymousGetCypherResults = genericGetCypherResults.MakeGenericMethod(anonType); var genericResultsTask = anonymousGetCypherResults.Invoke(graphClient, new object[] { cypherQuery }); await(Task) genericResultsTask; var genericResults = (IEnumerable)((dynamic)genericResultsTask).Result; var results = genericResults.Cast <object>().ToArray(); //Assert Assert.Equal(1, results.Length); var startNode = (ObjectWithIds)anonType.GetProperty(nameof(dummy.Start)).GetValue(results.First(), null); startNode.Ids.Count.Should().Be(3); startNode.Ids[0].Should().Be(1); startNode.Ids[1].Should().Be(2); startNode.Ids[2].Should().Be(3); var nodeWrapper = (ObjectWithNodeWithIds)anonType.GetProperty(nameof(dummy.Node)).GetValue(results.First(), null); nodeWrapper.Count.Should().Be(1); startNode = nodeWrapper.Node; startNode.Ids.Count.Should().Be(3); startNode.Ids[0].Should().Be(1); startNode.Ids[1].Should().Be(2); startNode.Ids[2].Should().Be(3); } }
public async Task RelationshipShouldDeserializeInAnonymousType() { // Arrange const string queryText = @"MATCH (n:Test)-[r]->(t:Test) RETURN r AS Rel"; var cypherQuery = new CypherQuery(queryText, new Dictionary <string, object>(), CypherResultMode.Projection, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { var relationshipMock = new Mock <IRelationship>(); relationshipMock .Setup(r => r.StartNodeId) .Returns(1); relationshipMock .Setup(r => r.EndNodeId) .Returns(2); relationshipMock .Setup(r => r.Type) .Returns("Xx"); relationshipMock .Setup(r => r.Id) .Returns(3); relationshipMock .Setup(r => r.Properties) .Returns(new Dictionary <string, object>() { { "Id", 42 } }); var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["Rel"]) .Returns(relationshipMock.Object); recordMock .Setup(r => r.Keys) .Returns(new[] { "Rel" }); var testStatementResult = new TestStatementResult(new[] { "Rel" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); //Session mock??? var dummy = new { Rel = new RelationType() }; var anonType = dummy.GetType(); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var genericGetCypherResults = typeof(IRawGraphClient).GetMethod(nameof(graphClient.ExecuteGetCypherResultsAsync)); var anonymousGetCypherResults = genericGetCypherResults.MakeGenericMethod(anonType); var genericResultsTask = anonymousGetCypherResults.Invoke(graphClient, new object[] { cypherQuery }); await(Task) genericResultsTask; var genericResults = (IEnumerable)((dynamic)genericResultsTask).Result; var results = genericResults.Cast <object>().ToArray(); //Assert Assert.Equal(1, results.Length); var relation = (RelationType)anonType.GetProperty(nameof(dummy.Rel)).GetValue(results.First(), null); relation.Id.Should().Be(42); } }
public async Task CollectionOfComplexTypesShouldDeserializeCorrectlyWhenInConjunctionWithAnotherComplexTypeInAContainer() { const string queryText = "MATCH (start:Node)-->(next:Node) RETURN start AS Start, collect(next) AS Next"; var queryParams = new Dictionary <string, object>(); var cypherQuery = new CypherQuery(queryText, queryParams, CypherResultMode.Projection, CypherResultFormat.Transactional, "neo4j"); using (var testHarness = new BoltTestHarness()) { var startNodeMock = new Mock <INode>(); startNodeMock .Setup(n => n.Id) .Returns(1); startNodeMock .Setup(n => n.Properties) .Returns(new Dictionary <string, object> { { "Id", 1 } }); var nextNodeMock = new Mock <INode>(); nextNodeMock .Setup(n => n.Id) .Returns(2); nextNodeMock .Setup(n => n.Properties) .Returns(new Dictionary <string, object> { { "Id", 2 } }); var recordMock = new Mock <IRecord>(); recordMock .Setup(r => r["Next"]) .Returns(new List <INode> { nextNodeMock.Object }); recordMock .Setup(r => r["Start"]) .Returns(startNodeMock.Object); recordMock .Setup(r => r.Keys) .Returns(new[] { "Start", "Next" }); var testStatementResult = new TestStatementResult(new[] { "Start", "Next" }, recordMock.Object); testHarness.SetupCypherRequestResponse(cypherQuery.QueryText, cypherQuery.QueryParameters, testStatementResult); var graphClient = await testHarness.CreateAndConnectBoltGraphClient(); var results = (await graphClient.ExecuteGetCypherResultsAsync <Container>(cypherQuery)).ToArray(); //Assert var deserializedObject = results.First(); deserializedObject.Start.Should().NotBeNull(); deserializedObject.Start.Id.Should().Be(1); var deserializedNext = deserializedObject.Next.ToList(); deserializedNext.Should().HaveCount(1); deserializedNext.First().Id.Should().Be(2); } }