public void ScanReturnsRows() { MockRepository mockRepository = new MockRepository(); IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>(); IHBaseRowData rowData1 = mockRepository.Stub<IHBaseRowData>(); IHBaseRowData rowData2 = mockRepository.Stub<IHBaseRowData>(); IHBaseRowData rowData3 = mockRepository.Stub<IHBaseRowData>(); HBaseDatabase db = new HBaseDatabase(connection); HBaseTable table = new HBaseTable(Encoding.UTF8.GetBytes("t"), db); byte[] startRow1 = Encoding.UTF8.GetBytes("start1"); byte[] startRow2 = Encoding.UTF8.GetBytes("start1"); byte[] startRow3 = Encoding.UTF8.GetBytes("start1"); byte[] stopRow = Encoding.UTF8.GetBytes("stop"); IList<byte[]> columns = new List<byte[]> { Encoding.UTF8.GetBytes("column") }; long? timestamp = 123; int? numRows = 400; using (mockRepository.Record()) { SetupResult.For(rowData1.Key).Return(startRow1); SetupResult.For(rowData1.Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>>()); SetupResult.For(rowData2.Key).Return(startRow2); SetupResult.For(rowData2.Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>>()); SetupResult.For(rowData3.Key).Return(startRow3); SetupResult.For(rowData3.Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>>()); SetupResult.For(connection.Scan(table.Name, startRow1, columns, timestamp, numRows)).Return(new List<IHBaseRowData> { rowData1 }); SetupResult.For(connection.ScanWithStop(table.Name, startRow2, stopRow, columns, timestamp, numRows)).Return(new List<IHBaseRowData> { rowData2 }); SetupResult.For(connection.ScanWithPrefix(table.Name, startRow3, columns, numRows)).Return(new List<IHBaseRowData> { rowData3 }); } using (mockRepository.Playback()) { var rows = table.Scan(startRow1, columns, timestamp, numRows); Assert.Contains(startRow1, rows.Select(r => r.Key)); rows = table.ScanWithStop(startRow2, stopRow, columns, timestamp, numRows); Assert.Contains(startRow2, rows.Select(r => r.Key)); rows = table.ScanWithPrefix(startRow3, columns, numRows); Assert.Contains(startRow3, rows.Select(r => r.Key)); } }
public void ScanRequiresStopRow() { MockRepository mockRepository = new MockRepository(); IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>(); HBaseDatabase db = new HBaseDatabase(connection); HBaseTable table = new HBaseTable(Encoding.UTF8.GetBytes("t"), db); Assert.Equal("stopRow", Assert.Throws<ArgumentNullException>(() => table.ScanWithStop(new byte[1], null, new List<byte[]> { new byte[1] })).ParamName); Assert.Equal("stopRow", Assert.Throws<ArgumentNullException>(() => table.ScanWithStop(new byte[1], new byte[0], new List<byte[]> { new byte[1] })).ParamName); }