public void TestRangeBasedAdd1() { IndexMap map = new IndexMap.RangeBased(); map = map.Add(0, 1); Assert.IsInstanceOf<IndexMap.RangeBased>(map); Assert.AreEqual(1, map.Map(0)); Assert.Throws<KeyNotFoundException>(() => map.Map(1)); }
public void TestMixedWith1Then1() { IndexMap map = new IndexMap.RangeBased(); map = map.Add(0, 1); Assert.IsInstanceOf<IndexMap.RangeBased>(map); map = map.Add(1, 3); Assert.IsInstanceOf<IndexMap.DictionaryBased>(map); Assert.AreEqual(1, map.Map(0)); Assert.AreEqual(3, map.Map(1)); Assert.Throws<KeyNotFoundException>(() => map.Map(2)); }
public void TestMixedWith2Then1() { IndexMap map = new IndexMap.RangeBased(); map = map.Add(0, 1); map = map.Add(1, 2); Assert.IsType<IndexMap.RangeBased>(map); map = map.Add(2, 4); Assert.IsType<IndexMap.DictionaryBased>(map); Assert.Equal(1, map.Map(0)); Assert.Equal(2, map.Map(1)); Assert.Equal(4, map.Map(2)); Assert.Throws<KeyNotFoundException>(() => map.Map(3)); }
// protected methods protected override BulkWriteBatchResult EmulateSingleRequest(MongoConnection connection, WriteRequest request, int originalIndex) { var serverInstance = connection.ServerInstance; var insertRequest = (InsertRequest)request; var insertRequests = new[] { insertRequest }; var operationArgs = new BulkInsertOperationArgs( _args.AssignId, _args.CheckElementNames, _args.CollectionName, _args.DatabaseName, 1, // maxBatchCount serverInstance.MaxMessageLength, // maxBatchLength serverInstance.MaxDocumentSize, serverInstance.MaxWireDocumentSize, true, // isOrdered _args.ReaderSettings, insertRequests, _args.WriteConcern, _args.WriterSettings); var operation = new InsertOpcodeOperation(operationArgs); WriteConcernResult writeConcernResult = null; WriteConcernException writeConcernException = null; try { var operationResult = operation.Execute(connection); if (operationResult != null) { writeConcernResult = operationResult.First(); } } catch (WriteConcernException ex) { writeConcernResult = ex.WriteConcernResult; writeConcernException = ex; } var indexMap = new IndexMap.RangeBased(0, originalIndex, 1); return BulkWriteBatchResult.Create( insertRequest, writeConcernResult, writeConcernException, indexMap); }
// protected methods protected override BulkWriteBatchResult EmulateSingleRequest(MongoConnection connection, WriteRequest request, int originalIndex) { var serverInstance = connection.ServerInstance; var deleteRequest = (DeleteRequest)request; var deleteRequests = new[] { deleteRequest }; var operationArgs = new BulkDeleteOperationArgs( _args.CollectionName, _args.DatabaseName, 1, // maxBatchCount serverInstance.MaxMessageLength, // maxBatchLength true, // isOrdered _args.ReaderSettings, deleteRequests, _args.WriteConcern, _args.WriterSettings); var operation = new DeleteOpcodeOperation(operationArgs); WriteConcernResult writeConcernResult; WriteConcernException writeConcernException = null; try { writeConcernResult = operation.Execute(connection); } catch (WriteConcernException ex) { writeConcernResult = ex.WriteConcernResult; writeConcernException = ex; } var indexMap = new IndexMap.RangeBased(0, originalIndex, 1); return BulkWriteBatchResult.Create( deleteRequest, writeConcernResult, writeConcernException, indexMap); }
private BulkWriteBatchResult ExecuteBatch(MongoConnection connection, Batch<WriteRequest> batch, int originalIndex) { var maxBatchCount = Math.Min(_args.MaxBatchCount, connection.ServerInstance.MaxBatchCount); var maxBatchLength = Math.Min(_args.MaxBatchLength, connection.ServerInstance.MaxDocumentSize); var maxDocumentSize = connection.ServerInstance.MaxDocumentSize; var maxWireDocumentSize = connection.ServerInstance.MaxWireDocumentSize; var batchSerializer = CreateBatchSerializer(maxBatchCount, maxBatchLength, maxDocumentSize, maxWireDocumentSize); var writeCommand = CreateWriteCommand(batchSerializer, batch); var writeCommandOperation = CreateWriteCommandOperation(writeCommand); var writeCommandResult = writeCommandOperation.Execute(connection); var batchProgress = batchSerializer.BatchProgress; var indexMap = new IndexMap.RangeBased(0, originalIndex, batchProgress.BatchCount); return BulkWriteBatchResult.Create( _args.IsOrdered, batchProgress.BatchItems, writeCommandResult.Response, indexMap, batchProgress.NextBatch); }
public void TestRangeBasedWith2() { var map = new IndexMap.RangeBased(0, 1, 2); Assert.AreEqual(1, map.Map(0)); Assert.AreEqual(2, map.Map(1)); Assert.Throws<KeyNotFoundException>(() => map.Map(2)); }
public void TestRangeBasedWith0() { var map = new IndexMap.RangeBased(); Assert.Throws<KeyNotFoundException>(() => map.Map(0)); }
private BulkWriteBatchResult ExecuteBatch(MongoConnection connection, Batch<WriteRequest> batch, int originalIndex) { var batchSerializer = CreateBatchSerializer(); var writeCommand = CreateWriteCommand(batchSerializer, batch); var writeCommandOperation = CreateWriteCommandOperation(writeCommand); var writeCommandResult = writeCommandOperation.Execute(connection); var batchProgress = batchSerializer.BatchProgress; var indexMap = new IndexMap.RangeBased(0, originalIndex, batchProgress.BatchCount); return BulkWriteBatchResult.Create( _args.IsOrdered, batchProgress.BatchItems, writeCommandResult.Response, indexMap, batchProgress.NextBatch); }
public void TestRangeBasedAdd2() { IndexMap map = new IndexMap.RangeBased(); map = map.Add(0, 1); map = map.Add(1, 2); Assert.IsType<IndexMap.RangeBased>(map); Assert.Equal(1, map.Map(0)); Assert.Equal(2, map.Map(1)); Assert.Throws<KeyNotFoundException>(() => map.Map(2)); }