public void GetRowsRequiresRows() { MockRepository mockRepository = new MockRepository(); IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>(); HBaseDatabase db = new HBaseDatabase(connection); HBaseTable table = new HBaseTable(Encoding.UTF8.GetBytes("stub"), db); Assert.Equal("rows", Assert.Throws<ArgumentNullException>(() => table.GetRows(null)).ParamName); Assert.Equal("rows", Assert.Throws<ArgumentException>(() => table.GetRows(new List<byte[]>())).ParamName); }
public void ReturnsRows() { MockRepository mockRepository = new MockRepository(); IHBaseConnection connection = mockRepository.Stub<IHBaseConnection>(); IList<IHBaseRowData> rowData = new List<IHBaseRowData>() { mockRepository.Stub<IHBaseRowData>() }; byte[] rowName = Encoding.UTF8.GetBytes("r"); byte[] columnName = Encoding.UTF8.GetBytes("r"); byte[] tableName = Encoding.UTF8.GetBytes("t"); using (mockRepository.Record()) { SetupResult.For( connection .GetRows( new List<byte[]> { rowName }, tableName, new List<byte[]> { columnName }, 123)) .Return(rowData); SetupResult.For(rowData[0].Columns).Return(new Dictionary<byte[], IList<IHBaseCellData>>()); SetupResult.For(rowData[0].Key).Return(rowName); } using (mockRepository.Playback()) { HBaseDatabase db = new HBaseDatabase(connection); HBaseTable table = new HBaseTable(tableName, db); var rows = table.GetRows( new List<byte[]> { rowName }, new List<byte[]> { columnName }, 123); Assert.Contains(rowName, rows.Select(r => r.Key).ToList()); } }