public async Task DistinctResult() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.SingleResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestDistinctResult <Person>(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Age, 27); Assert.Equal(result.Result.Fullname, "raoof hojat"); Assert.Equal(result.Result.Height, 172); var info = mockDB.Db.FindDocumentInfo(result.Result); Assert.Equal(info.Id, "Person/KEY"); Assert.Equal(info.Key, "KEY"); Assert.Equal(info.Rev, "REV"); Assert.True(JObject.DeepEquals(info.Document, JObject.Parse(JsonSample.SingleResult))); }
public async Task RequestGenericSingle() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.NestedSingleResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericSingleResult <Person, DocumentInheritedCommandResult <Person> >(); Assert.Equal(200, result.BaseResult.Code); Assert.False(result.BaseResult.Error); Assert.Equal(27, result.Result.Age); Assert.Equal("raoof hojat", result.Result.Fullname); Assert.Equal(172, result.Result.Height); var info = mockDB.Db.FindDocumentInfo(result.Result); Assert.Equal("Person/KEY", info.Id); Assert.Equal("KEY", info.Key); Assert.Equal("REV", info.Rev); Assert.True(JObject.DeepEquals(info.Document, JObject.Parse(JsonSample.SingleResult))); }
public async Task RequestGenericList_WithoutChangeTracking() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.ListResult); mockDB.Db.Setting.DisableChangeTracking = true; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericListResult <Person, DocumentInheritedCommandResult <List <Person> > >(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Count, 2); Assert.Equal(result.Result[0].Age, 27); Assert.Equal(result.Result[0].Fullname, "raoof hojat"); Assert.Equal(result.Result[0].Height, 172); Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(result.Result[0])); Assert.Equal(result.Result[1].Age, 7); Assert.Equal(result.Result[1].Fullname, "hojat raoof"); Assert.Equal(result.Result[1].Height, 721); Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(result.Result[1])); }
public async Task DistinctResult_BadRequest() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; await Assert.ThrowsAsync<ArangoServerException>(() => command.RequestDistinctResult<Person>()); }
public async Task DistinctResult_BadRequest() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; await Assert.ThrowsAsync <ArangoServerException>(() => command.RequestDistinctResult <Person>()); }
public async Task RequestGenericList_WithoutChangeTracking_BadRequest() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); mockDB.Db.Setting.DisableChangeTracking = true; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; await Assert.ThrowsAsync <ArangoServerException>(() => command.RequestGenericListResult <Person, DocumentInheritedCommandResult <List <Person> > >()); }
public async Task RequestGenericList_BadRequest_DontThrow() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); mockDB.Db.Setting.ThrowForServerErrors = false; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericListResult <Person, DocumentInheritedCommandResult <List <Person> > >(); Assert.Equal(result.Result.Count, 0); Assert.Equal(result.BaseResult.Code, 400); Assert.Equal(result.BaseResult.Error, true); Assert.Equal(result.BaseResult.ErrorMessage, "ERROR"); }
public async Task RequestMerged_BadRequest_DontThrow() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); mockDB.Db.Setting.ThrowForServerErrors = false; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestMergedResult <Flight>(); Assert.Null(result.Result); Assert.Equal(result.BaseResult.Code, 400); Assert.Equal(result.BaseResult.Error, true); Assert.Equal(result.BaseResult.ErrorMessage, "ERROR"); }
public async Task DistinctResult_WithoutChangeTracking_BadRequest_DontThrow() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); mockDB.Db.Setting.DisableChangeTracking = true; mockDB.Db.Setting.ThrowForServerErrors = false; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestDistinctResult <Person>(); Assert.Null(result.Result); Assert.Equal(400, result.BaseResult.Code); Assert.True(result.BaseResult.Error); Assert.Equal("ERROR", result.BaseResult.ErrorMessage); }
public async Task DistinctResult_WithoutChangeTracking() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.SingleResult); mockDB.Db.Setting.DisableChangeTracking = true; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestDistinctResult<Person>(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Age, 27); Assert.Equal(result.Result.Fullname, "raoof hojat"); Assert.Equal(result.Result.Height, 172); Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(result.Result)); }
public async Task RequestMergedResult() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.MergeResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestMergedResult <Flight>(); Assert.Equal(result.BaseResult.Code, 202); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Airline, "AIRLINE"); Assert.Equal(result.Result.FlightNumber, "10012314"); Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(result.Result)); }
public async Task RequestGenericList() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.ListResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericListResult <Person, DocumentInheritedCommandResult <List <Person> > >(); Assert.Equal(200, result.BaseResult.Code); Assert.False(result.BaseResult.Error); Assert.Equal(2, result.Result.Count); Assert.Equal(27, result.Result[0].Age); Assert.Equal("raoof hojat", result.Result[0].Fullname); Assert.Equal(172, result.Result[0].Height); var info1 = mockDB.Db.FindDocumentInfo(result.Result[0]); Assert.Equal("Person/KEY1", info1.Id); Assert.Equal("KEY1", info1.Key); Assert.Equal("REV1", info1.Rev); Assert.Equal(7, result.Result[1].Age); Assert.Equal("hojat raoof", result.Result[1].Fullname); Assert.Equal(721, result.Result[1].Height); var info2 = mockDB.Db.FindDocumentInfo(result.Result[1]); Assert.NotNull(info2.Document); Assert.Equal("Person/KEY2", info2.Id); Assert.Equal("KEY2", info2.Key); Assert.Equal("REV2", info2.Rev); }
public async Task RequestGenericList() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.ListResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericListResult <Person, DocumentInheritedCommandResult <List <Person> > >(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Count, 2); Assert.Equal(result.Result[0].Age, 27); Assert.Equal(result.Result[0].Fullname, "raoof hojat"); Assert.Equal(result.Result[0].Height, 172); var info1 = mockDB.Db.FindDocumentInfo(result.Result[0]); Assert.Equal(info1.Id, "Person/KEY1"); Assert.Equal(info1.Key, "KEY1"); Assert.Equal(info1.Rev, "REV1"); Assert.Equal(result.Result[1].Age, 7); Assert.Equal(result.Result[1].Fullname, "hojat raoof"); Assert.Equal(result.Result[1].Height, 721); var info2 = mockDB.Db.FindDocumentInfo(result.Result[1]); Assert.NotNull(info2.Document); Assert.Equal(info2.Id, "Person/KEY2"); Assert.Equal(info2.Key, "KEY2"); Assert.Equal(info2.Rev, "REV2"); }
public async Task DistinctResult() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.SingleResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestDistinctResult<Person>(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Age, 27); Assert.Equal(result.Result.Fullname, "raoof hojat"); Assert.Equal(result.Result.Height, 172); var info = mockDB.Db.FindDocumentInfo(result.Result); Assert.Equal(info.Id, "Person/KEY"); Assert.Equal(info.Key, "KEY"); Assert.Equal(info.Rev, "REV"); Assert.True(JObject.DeepEquals(info.Document, JObject.Parse(JsonSample.SingleResult))); }
public async Task DistinctResult_WithoutChangeTracking() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.SingleResult); mockDB.Db.Setting.DisableChangeTracking = true; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestDistinctResult <Person>(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Age, 27); Assert.Equal(result.Result.Fullname, "raoof hojat"); Assert.Equal(result.Result.Height, 172); Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(result.Result)); }
public async Task RequestGenericSingle_WithoutChangeTracking() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.NestedSingleResult); mockDB.Db.Setting.DisableChangeTracking = true; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericSingleResult <Person, DocumentInheritedCommandResult <Person> >(); Assert.Equal(200, result.BaseResult.Code); Assert.False(result.BaseResult.Error); Assert.Equal(27, result.Result.Age); Assert.Equal("raoof hojat", result.Result.Fullname); Assert.Equal(172, result.Result.Height); Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(result.Result)); }
void CreateRequestCursor(string json = null, IList <string> jsonList = null, bool?disableChangeTracking = false, bool?error = false, bool?throwOnError = true) { bool hasMore = string.IsNullOrEmpty(json); var mockDB = new ArangoDatabaseMock().WithChangeTracking(); if (!hasMore) { mockDB.SendCommand(json, statusCode: error.Value ? HttpStatusCode.NotFound : HttpStatusCode.OK); } else { mockDB.SendCommandSequence(jsonList, statusCode: error.Value ? HttpStatusCode.NotFound : HttpStatusCode.OK); } mockDB.Db.Setting.DisableChangeTracking = disableChangeTracking.Value; mockDB.Db.Setting.ThrowForServerErrors = throwOnError.Value; HttpCommand command = new HttpCommand(mockDB.Db); var cursor = command.CreateCursor <Person>(); if (error.Value) { if (throwOnError.Value) { Assert.Throws <ArangoServerException>(() => cursor.ToList()); } else { var persons = cursor.ToList(); Assert.Equal(persons.Count, 0); Assert.Equal(cursor.Statistics.Code, 400); Assert.Equal(cursor.Statistics.Error, true); Assert.Equal(cursor.Statistics.ErrorMessage, "ERROR"); } } else { var persons = cursor.ToList(); Assert.Equal(cursor.Statistics.Code, 201); Assert.Equal(cursor.Statistics.Count, 2); Assert.Equal(cursor.Statistics.Error, false); Assert.Equal(cursor.Statistics.Id, "26011191"); Assert.Equal(cursor.Statistics.RequestCount, hasMore ? 2 : 1); Assert.Equal(cursor.Statistics.HasMore, false); Assert.Equal(cursor.Statistics.Extra.Stats.FullCount, 6); Assert.Equal(cursor.Statistics.Extra.Stats.ScannedFull, 3); Assert.Equal(cursor.Statistics.Extra.Stats.ScannedIndex, 4); Assert.Equal(cursor.Statistics.Extra.Stats.WritesExecuted, 1); Assert.Equal(cursor.Statistics.Extra.Stats.WritesIgnored, 2); Assert.Equal(persons.Count, hasMore ? 4 : 2); int index = 0; if (hasMore) { Assert.Equal(persons[index].Age, 27); Assert.Equal(persons[index].Fullname, "raoof hojat2"); Assert.Equal(persons[index].Height, 172); if (disableChangeTracking.Value) { Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); } else { var info3 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.Equal(info3.Id, "Person/KEY3"); Assert.Equal(info3.Key, "KEY3"); Assert.Equal(info3.Rev, "REV3"); } index++; Assert.Equal(persons[index].Age, 7); Assert.Equal(persons[index].Fullname, "hojat raoof2"); Assert.Equal(persons[index].Height, 721); if (disableChangeTracking.Value) { Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); } else { var info4 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.NotNull(info4.Document); Assert.Equal(info4.Id, "Person/KEY4"); Assert.Equal(info4.Key, "KEY4"); Assert.Equal(info4.Rev, "REV4"); } index++; } Assert.Equal(persons[index].Age, 27); Assert.Equal(persons[index].Fullname, "raoof hojat"); Assert.Equal(persons[index].Height, 172); if (disableChangeTracking.Value) { Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); } else { var info1 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.Equal(info1.Id, "Person/KEY1"); Assert.Equal(info1.Key, "KEY1"); Assert.Equal(info1.Rev, "REV1"); } index++; Assert.Equal(persons[index].Age, 7); Assert.Equal(persons[index].Fullname, "hojat raoof"); Assert.Equal(persons[index].Height, 721); if (disableChangeTracking.Value) { Assert.Throws <Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); } else { var info2 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.NotNull(info2.Document); Assert.Equal(info2.Id, "Person/KEY2"); Assert.Equal(info2.Key, "KEY2"); Assert.Equal(info2.Rev, "REV2"); } } }
public async Task RequestGenericList_WithoutChangeTracking() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.ListResult); mockDB.Db.Setting.DisableChangeTracking = true; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericListResult<Person, DocumentInheritedCommandResult<List<Person>>>(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Count, 2); Assert.Equal(result.Result[0].Age, 27); Assert.Equal(result.Result[0].Fullname, "raoof hojat"); Assert.Equal(result.Result[0].Height, 172); Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(result.Result[0])); Assert.Equal(result.Result[1].Age, 7); Assert.Equal(result.Result[1].Fullname, "hojat raoof"); Assert.Equal(result.Result[1].Height, 721); Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(result.Result[1])); }
public async Task RequestGenericList_WithoutChangeTracking_BadRequest() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); mockDB.Db.Setting.DisableChangeTracking = true; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; await Assert.ThrowsAsync<ArangoServerException>(() => command.RequestGenericListResult<Person, DocumentInheritedCommandResult<List<Person>>>()); }
public async Task RequestMergedResult() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.MergeResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking}; var result = await command.RequestMergedResult<Flight>(); Assert.Equal(result.BaseResult.Code, 202); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Airline, "AIRLINE"); Assert.Equal(result.Result.FlightNumber, "10012314"); Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(result.Result)); }
void CreateRequestCursor(string json = null, IList<string> jsonList = null, bool? disableChangeTracking = false, bool? error = false, bool? throwOnError = true) { bool hasMore = string.IsNullOrEmpty(json); var mockDB = new ArangoDatabaseMock().WithChangeTracking(); if (!hasMore) mockDB.SendCommand(json, statusCode: error.Value ? HttpStatusCode.NotFound : HttpStatusCode.OK); else mockDB.SendCommandSequence(jsonList, statusCode: error.Value ? HttpStatusCode.NotFound : HttpStatusCode.OK); mockDB.Db.Setting.DisableChangeTracking = disableChangeTracking.Value; mockDB.Db.Setting.ThrowForServerErrors = throwOnError.Value; HttpCommand command = new HttpCommand(mockDB.Db); var cursor = command.CreateCursor<Person>(); if (error.Value) { if (throwOnError.Value) Assert.Throws<ArangoServerException>(() => cursor.ToList()); else { var persons = cursor.ToList(); Assert.Equal(persons.Count, 0); Assert.Equal(cursor.Statistics.Code, 400); Assert.Equal(cursor.Statistics.Error, true); Assert.Equal(cursor.Statistics.ErrorMessage, "ERROR"); } } else { var persons = cursor.ToList(); Assert.Equal(cursor.Statistics.Code, 201); Assert.Equal(cursor.Statistics.Count, 2); Assert.Equal(cursor.Statistics.Error, false); Assert.Equal(cursor.Statistics.Id, "26011191"); Assert.Equal(cursor.Statistics.RequestCount, hasMore ? 2 : 1); Assert.Equal(cursor.Statistics.HasMore, false); Assert.Equal(cursor.Statistics.Extra.Stats.FullCount, 6); Assert.Equal(cursor.Statistics.Extra.Stats.ScannedFull, 3); Assert.Equal(cursor.Statistics.Extra.Stats.ScannedIndex, 4); Assert.Equal(cursor.Statistics.Extra.Stats.WritesExecuted, 1); Assert.Equal(cursor.Statistics.Extra.Stats.WritesIgnored, 2); Assert.Equal(persons.Count, hasMore ? 4 : 2); int index = 0; if (hasMore) { Assert.Equal(persons[index].Age, 27); Assert.Equal(persons[index].Fullname, "raoof hojat2"); Assert.Equal(persons[index].Height, 172); if (disableChangeTracking.Value) Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); else { var info3 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.Equal(info3.Id, "Person/KEY3"); Assert.Equal(info3.Key, "KEY3"); Assert.Equal(info3.Rev, "REV3"); } index++; Assert.Equal(persons[index].Age, 7); Assert.Equal(persons[index].Fullname, "hojat raoof2"); Assert.Equal(persons[index].Height, 721); if (disableChangeTracking.Value) Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); else { var info4 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.NotNull(info4.Document); Assert.Equal(info4.Id, "Person/KEY4"); Assert.Equal(info4.Key, "KEY4"); Assert.Equal(info4.Rev, "REV4"); } index++; } Assert.Equal(persons[index].Age, 27); Assert.Equal(persons[index].Fullname, "raoof hojat"); Assert.Equal(persons[index].Height, 172); if (disableChangeTracking.Value) Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); else { var info1 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.Equal(info1.Id, "Person/KEY1"); Assert.Equal(info1.Key, "KEY1"); Assert.Equal(info1.Rev, "REV1"); } index++; Assert.Equal(persons[index].Age, 7); Assert.Equal(persons[index].Fullname, "hojat raoof"); Assert.Equal(persons[index].Height, 721); if (disableChangeTracking.Value) Assert.Throws<Exception>(() => mockDB.Db.FindDocumentInfo(persons[index])); else { var info2 = mockDB.Db.FindDocumentInfo(persons[index]); Assert.NotNull(info2.Document); Assert.Equal(info2.Id, "Person/KEY2"); Assert.Equal(info2.Key, "KEY2"); Assert.Equal(info2.Rev, "REV2"); } } }
public async Task DistinctResult_BadRequest_DontThrow() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.Error, statusCode: HttpStatusCode.NotFound); mockDB.Db.Setting.ThrowForServerErrors = false; HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestDistinctResult<Person>(); Assert.Null(result.Result); Assert.Equal(result.BaseResult.Code, 400); Assert.Equal(result.BaseResult.Error, true); Assert.Equal(result.BaseResult.ErrorMessage, "ERROR"); }
public async Task RequestGenericList() { var mockDB = new ArangoDatabaseMock().WithChangeTracking(); mockDB.SendCommand(JsonSample.ListResult); HttpCommand command = new HttpCommand(mockDB.Db) { EnableChangeTracking = !mockDB.Db.Setting.DisableChangeTracking }; var result = await command.RequestGenericListResult<Person, DocumentInheritedCommandResult<List<Person>>>(); Assert.Equal(result.BaseResult.Code, 200); Assert.Equal(result.BaseResult.Error, false); Assert.Equal(result.Result.Count, 2); Assert.Equal(result.Result[0].Age, 27); Assert.Equal(result.Result[0].Fullname, "raoof hojat"); Assert.Equal(result.Result[0].Height, 172); var info1 = mockDB.Db.FindDocumentInfo(result.Result[0]); Assert.Equal(info1.Id, "Person/KEY1"); Assert.Equal(info1.Key, "KEY1"); Assert.Equal(info1.Rev, "REV1"); Assert.Equal(result.Result[1].Age, 7); Assert.Equal(result.Result[1].Fullname, "hojat raoof"); Assert.Equal(result.Result[1].Height, 721); var info2 = mockDB.Db.FindDocumentInfo(result.Result[1]); Assert.NotNull(info2.Document); Assert.Equal(info2.Id, "Person/KEY2"); Assert.Equal(info2.Key, "KEY2"); Assert.Equal(info2.Rev, "REV2"); }