public void Execute_with_hint_should_throw_when_hint_is_not_supported( [Values(0, 1)] int w, [Values(false, true)] bool async) { var writeConcern = new WriteConcern(w); var request = new UpdateRequest( UpdateType.Update, new BsonDocument("x", 1), new BsonDocument("$set", new BsonDocument("x", 2))) { Hint = new BsonDocument("_id", 1) }; var subject = new UpdateOpcodeOperation(_collectionNamespace, request, _messageEncoderSettings) { WriteConcern = writeConcern }; var exception = Record.Exception(() => ExecuteOperation(subject, async)); if (!writeConcern.IsAcknowledged) { exception.Should().BeOfType <NotSupportedException>(); } #pragma warning disable CS0618 // Type or member is obsolete else if (Feature.HintForUpdateAndReplaceOperations.IsSupported(CoreTestConfiguration.MaxWireVersion)) #pragma warning restore CS0618 // Type or member is obsolete { exception.Should().BeNull(); } else { exception.Should().BeOfType <MongoCommandException>(); } }
// constructors public Builder(UpdateOpcodeOperation other) { _collectionName = other.CollectionName; _databaseName = other.DatabaseName; _isMulti = other.IsMulti; _isUpsert = other.IsUpsert; _maxDocumentSize = other.MaxDocumentSize; _query = other.Query; _update = other.Update; _writeConcern = other.WriteConcern; }