public void ShouldNotFailIfOnNullDocumentRowsFromCouchDb() { var dbApiMock = new Mock <IDatabaseApi>(); dbApiMock .Setup(a => a.Query(It.IsAny <ViewQuery>())) .Returns( (ViewQuery query) => new ViewQueryResult(query: query, rows: new[] { new ViewResultRow( new object[] { "key1", 0 }.ToJsonFragment(), new { Title = "Object title", Subject = "some" }.ToJsonFragment(), null, null ) }, totalCount: 1, offset: 0).ToTask <IViewQueryResult>() ); var session = new CouchSession(Default.Settings, Mock.Of <ICouchApi>(c => c.Db("testdb") == dbApiMock.Object)); IViewQueryResult <Entity> queryResult = session.Synchronously.Query <Entity>(new ViewQuery { IncludeDocs = true }); Assert.Equal(1, queryResult.Count); Assert.Equal(1, queryResult.Count()); Assert.Null(queryResult.First()); }
public void ShouldNotFailIfOnNullValueRowsFromCouchDB() { var dbApiMock = new Mock <IDatabaseApi>(); dbApiMock .Setup(a => a.Query(It.IsAny <ViewQuery>())) .Returns( (ViewQuery query) => new ViewQueryResult(query: query, rows: new[] { new ViewResultRow( new object[] { "key1", 0 }.ToJsonFragment(), null, Entity.StandardDocId, Entity.CreateDocWithRevision() ) }, totalCount: 1, offset: 0).ToTask <IViewQueryResult>() ); var session = new CouchSession(Default.Settings, Mock.Of <ICouchApi>(c => c.Db("testdb") == dbApiMock.Object)); IViewQueryResult <ViewData> queryResult = session.Synchronously.Query <ViewData>(new ViewQuery()); Assert.Equal(1, queryResult.Count); Assert.Equal(1, queryResult.Count()); Assert.Null(queryResult.First()); }