Skip to content

Commit b3764df

Browse files
committed
Use enum values for error code assertions in GraphApiClientTest.
1 parent 1248521 commit b3764df

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

arangodb-net-standard.Test/GraphApi/GraphApiClientTest.cs

+28-26
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
using System.Threading.Tasks;
1111
using Xunit;
1212

13+
using static ArangoDBNetStandard.ArangoDBErrors;
14+
1315
namespace ArangoDBNetStandardTest.GraphApi
1416
{
1517
public class GraphApiClientTest : IClassFixture<GraphApiClientTestFixture>
@@ -81,7 +83,7 @@ public async Task DeleteGraphAsync_ShouldThrow_WhenNotFound()
8183
});
8284

8385
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
84-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
86+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
8587
}
8688

8789
[Fact]
@@ -107,7 +109,7 @@ public async Task GetGraphAsync_ShouldThrow_WhenNotFound()
107109
await _client.GetGraphAsync("bogus_graph");
108110
});
109111
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
110-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
112+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
111113
}
112114

113115
[Fact]
@@ -164,7 +166,7 @@ public async Task GetVertexCollectionsAsync_ShouldThrow_WhenGraphDoesNotExist()
164166
ApiErrorResponse apiError = ex.ApiError;
165167

166168
Assert.Equal(HttpStatusCode.NotFound, apiError.Code);
167-
Assert.Equal(1924, apiError.ErrorNum);
169+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, apiError.ErrorNum);
168170
}
169171

170172
[Fact]
@@ -184,7 +186,7 @@ public async Task GetEdgeCollectionsAsync_ShouldThrow_WhenGraphIsNotFound()
184186
await _client.GetEdgeCollectionsAsync("bogus_graph");
185187
});
186188
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
187-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
189+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
188190
}
189191

190192
[Fact]
@@ -309,7 +311,7 @@ await _client.PostEdgeDefinitionAsync(
309311
});
310312

311313
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
312-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
314+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
313315
}
314316

315317
[Fact]
@@ -361,7 +363,7 @@ public async Task PostVertexCollectionAsync_ShouldThrow_WhenGraphIsNotFound()
361363

362364
Assert.True(apiError.Error);
363365
Assert.Equal(HttpStatusCode.NotFound, apiError.Code);
364-
Assert.Equal(1924, apiError.ErrorNum); // ERROR_GRAPH_NOT_FOUND
366+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, apiError.ErrorNum);
365367
}
366368

367369
[Fact]
@@ -411,7 +413,7 @@ public async Task PostVertexAsync_ShouldThrow_WhenGraphIsNotFound()
411413

412414
Assert.True(ex.ApiError.Error);
413415
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
414-
Assert.Equal(1924, ex.ApiError.ErrorNum); // ERROR_GRAPH_NOT_FOUND
416+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
415417
}
416418

417419
[Fact]
@@ -436,11 +438,11 @@ public async Task PostVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
436438
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
437439
if (_fixture.VersionMajor >= 3 && _fixture.VersionMinor >= 10)
438440
{
439-
Assert.Equal(1947, ex.ApiError.ErrorNum); //referenced vertex collection is not part of the graph
441+
Assert.Equal((int)ERROR_GRAPH_REFERENCED_VERTEX_COLLECTION_NOT_USED, ex.ApiError.ErrorNum);
440442
}
441443
else
442444
{
443-
Assert.Equal(1203, ex.ApiError.ErrorNum); // ARANGO_DATA_SOURCE_NOT_FOUND
445+
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
444446
}
445447
}
446448

@@ -561,7 +563,7 @@ public async Task DeleteEdgeDefinitionAsync_ShouldThrow_WhenGraphNameDoesNotExis
561563
});
562564

563565
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
564-
Assert.Equal(1924, ex.ApiError.ErrorNum); // GRAPH_NOT_FOUND
566+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
565567
}
566568

567569
[Fact]
@@ -611,7 +613,7 @@ public async Task DeleteVertexCollectionAsync_ShouldThrow_WhenGraphIsNotFound()
611613

612614
Assert.True(ex.ApiError.Error);
613615
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
614-
Assert.Equal(1924, ex.ApiError.ErrorNum); // ERROR_GRAPH_NOT_FOUND
616+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
615617
}
616618

617619
[Fact]
@@ -671,7 +673,7 @@ public async Task DeleteVertexCollectionAsync_ShouldDropCollection_WhenDropColle
671673
await _fixture.ArangoDBClient.Collection.GetCollectionAsync(clxToDelete);
672674
});
673675
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
674-
Assert.Equal(1203, ex.ApiError.ErrorNum); // ARANGO_DATA_SOURCE_NOT_FOUND
676+
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
675677
}
676678

677679
[Fact]
@@ -751,7 +753,7 @@ public async Task PostEdgeAsync_ShouldThrow_WhenGraphNotFound()
751753
});
752754

753755
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
754-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
756+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
755757
}
756758

757759
[Fact]
@@ -868,7 +870,7 @@ public async Task DeleteEdgeAsync_ShouldThrow_WhenGraphNotFound()
868870
});
869871

870872
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
871-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
873+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
872874
}
873875

874876
[Fact]
@@ -944,7 +946,7 @@ public async Task GetVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
944946

945947
Assert.True(ex.ApiError.Error);
946948
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
947-
Assert.Equal(1203, ex.ApiError.ErrorNum); // ARANGO_DATA_SOURCE_NOT_FOUND
949+
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
948950
}
949951

950952
[Fact]
@@ -990,7 +992,7 @@ public async Task GetVertexAsync_ShouldThrow_WhenGraphIsNotFound()
990992

991993
Assert.True(ex.ApiError.Error);
992994
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
993-
Assert.Equal(1924, ex.ApiError.ErrorNum); // ERROR_GRAPH_NOT_FOUND
995+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
994996
}
995997

996998
[Fact]
@@ -1078,7 +1080,7 @@ public async Task DeleteVertexAsync_ShouldThrow_WhenGraphIsNotFound()
10781080

10791081
Assert.True(ex.ApiError.Error);
10801082
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1081-
Assert.Equal(1924, ex.ApiError.ErrorNum); // ERROR_GRAPH_NOT_FOUND
1083+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
10821084
}
10831085

10841086
[Fact]
@@ -1101,7 +1103,7 @@ public async Task DeleteVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
11011103

11021104
Assert.True(ex.ApiError.Error);
11031105
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1104-
Assert.Equal(1203, ex.ApiError.ErrorNum); // ARANGO_DATA_SOURCE_NOT_FOUND
1106+
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
11051107
}
11061108

11071109
[Fact]
@@ -1231,7 +1233,7 @@ public async Task PatchVertexAsync_ShouldThrow_WhenGraphIsNotFound()
12311233

12321234
Assert.True(ex.ApiError.Error);
12331235
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1234-
Assert.Equal(1924, ex.ApiError.ErrorNum); // ERROR_GRAPH_NOT_FOUND
1236+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
12351237
}
12361238

12371239
[Fact]
@@ -1254,7 +1256,7 @@ public async Task PatchVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
12541256

12551257
Assert.True(ex.ApiError.Error);
12561258
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1257-
Assert.Equal(1203, ex.ApiError.ErrorNum); // ARANGO_DATA_SOURCE_NOT_FOUND
1259+
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
12581260
}
12591261

12601262
[Fact]
@@ -1406,7 +1408,7 @@ public async Task PuGraphEdgeAsync_ShouldThrow_WhenGraphNotFound()
14061408
});
14071409

14081410
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
1409-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
1411+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
14101412
}
14111413

14121414
[Fact]
@@ -1453,7 +1455,7 @@ public async Task PutEdgeDefinitionAsync_ShouldThrow_WhenGraphNameDoesNotExist()
14531455
});
14541456

14551457
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1456-
Assert.Equal(1924, ex.ApiError.ErrorNum); // GRAPH_NOT_FOUND
1458+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
14571459
}
14581460

14591461
[Fact]
@@ -1632,7 +1634,7 @@ public async Task GetEdgeAsync_ShouldThrow_WhenGraphIsNotFound()
16321634
});
16331635

16341636
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
1635-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
1637+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
16361638
}
16371639

16381640
[Fact]
@@ -1754,7 +1756,7 @@ public async Task PatchEdgeAsync_ShouldThrow_WhenGraphNotFound()
17541756
});
17551757

17561758
Assert.Equal(HttpStatusCode.NotFound, exception.ApiError.Code);
1757-
Assert.Equal(1924, exception.ApiError.ErrorNum); // GRAPH_NOT_FOUND
1759+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, exception.ApiError.ErrorNum);
17581760
}
17591761

17601762
[Fact]
@@ -1849,7 +1851,7 @@ public async Task PutVertexAsync_ShouldThrow_WhenGraphIsNotFound()
18491851

18501852
Assert.True(ex.ApiError.Error);
18511853
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1852-
Assert.Equal(1924, ex.ApiError.ErrorNum); // ERROR_GRAPH_NOT_FOUND
1854+
Assert.Equal((int)ERROR_GRAPH_NOT_FOUND, ex.ApiError.ErrorNum);
18531855
}
18541856

18551857
[Fact]
@@ -1869,7 +1871,7 @@ public async Task PutVertexAsync_ShouldThrow_WhenVertexCollectionIsNotFound()
18691871
});
18701872
Assert.True(ex.ApiError.Error);
18711873
Assert.Equal(HttpStatusCode.NotFound, ex.ApiError.Code);
1872-
Assert.Equal(1203, ex.ApiError.ErrorNum); // ARANGO_DATA_SOURCE_NOT_FOUND
1874+
Assert.Equal((int)ERROR_ARANGO_DATA_SOURCE_NOT_FOUND, ex.ApiError.ErrorNum);
18731875
}
18741876

18751877
[Fact]

0 commit comments

Comments
 (0)