本文整理汇总了C#中FindCommandOperation.CreateCommand方法的典型用法代码示例。如果您正苦于以下问题:C# FindCommandOperation.CreateCommand方法的具体用法?C# FindCommandOperation.CreateCommand怎么用?C# FindCommandOperation.CreateCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FindCommandOperation
的用法示例。
在下文中一共展示了FindCommandOperation.CreateCommand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCommand_should_throw_when_Collation_is_set_but_not_supported
public void CreateCommand_should_throw_when_Collation_is_set_but_not_supported()
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Collation = new Collation("en_US")
};
var exception = Record.Exception(() => subject.CreateCommand(Feature.Collation.LastNotSupportedVersion, 0));
exception.Should().BeOfType<NotSupportedException>();
}
示例2: CreateCommand_should_throw_when_ReadConcern_is_set_but_not_supported
public void CreateCommand_should_throw_when_ReadConcern_is_set_but_not_supported()
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
ReadConcern = new ReadConcern(ReadConcernLevel.Local)
};
var exception = Record.Exception(() => subject.CreateCommand(Feature.ReadConcern.LastNotSupportedVersion, 0));
exception.Should().BeOfType<MongoClientException>();
}
示例3: CreateCommand_should_return_expected_result_when_Snapshot_is_set
public void CreateCommand_should_return_expected_result_when_Snapshot_is_set(
[Values(null, false, true)]
bool? snapshot)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Snapshot = snapshot
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "snapshot", () => snapshot.Value, snapshot.HasValue }
};
result.Should().Be(expectedResult);
}
示例4: CreateCommand_should_return_expected_result_when_Sort_is_set
public void CreateCommand_should_return_expected_result_when_Sort_is_set(
[Values(null, "{ x : 1 }", "{ y : 1 }")]
string sortString)
{
var sort = sortString == null ? null : BsonDocument.Parse(sortString);
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Sort = sort
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "sort", sort, sort != null }
};
result.Should().Be(expectedResult);
}
示例5: CreateCommand_should_return_expected_result_when_ReadConcern_is_set
public void CreateCommand_should_return_expected_result_when_ReadConcern_is_set(
[Values(null, ReadConcernLevel.Linearizable, ReadConcernLevel.Local)]
ReadConcernLevel? level)
{
var readConcern = level.HasValue ? new ReadConcern(level.Value) : ReadConcern.Default;
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
ReadConcern = readConcern
};
var result = subject.CreateCommand(Feature.ReadConcern.FirstSupportedVersion, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "readConcern", () => readConcern.ToBsonDocument(), readConcern != null && !readConcern.IsServerDefault }
};
result.Should().Be(expectedResult);
}
示例6: CreateCommand_should_return_expected_result_when_Skip_is_set
public void CreateCommand_should_return_expected_result_when_Skip_is_set(
[Values(null, 0, 1, 2)]
int? skip)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Skip = skip
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "skip", () => skip.Value, skip.HasValue }
};
result.Should().Be(expectedResult);
}
示例7: CreateCommand_should_return_expected_result_when_Limit_is_set
public void CreateCommand_should_return_expected_result_when_Limit_is_set(
[Values(null, -2, -1, 0, 1, 2)]
int? limit,
[Values(null, false, true)]
bool? singleBatch)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Limit = limit,
SingleBatch = singleBatch
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "limit", () => Math.Abs(limit.Value), limit.HasValue && limit.Value != 0 },
{ "singleBatch", () => limit < 0 || singleBatch.Value, limit < 0 || singleBatch.HasValue }
};
result.Should().Be(expectedResult);
}
示例8: CreateCommand_should_return_expected_result_when_MaxTime_is_set
public void CreateCommand_should_return_expected_result_when_MaxTime_is_set(
[Values(null, 1, 2)]
int? seconds)
{
var maxTime = seconds.HasValue ? TimeSpan.FromSeconds(seconds.Value) : (TimeSpan?)null;
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
MaxTime = maxTime
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "maxTimeMS", () => seconds.Value * 1000, seconds.HasValue }
};
result.Should().Be(expectedResult);
}
示例9: CreateCommand_should_return_expected_result_when_FirstBatchSize_is_set
public void CreateCommand_should_return_expected_result_when_FirstBatchSize_is_set(
[Values(null, 0, 1)]
int? firstBatchSize)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
FirstBatchSize = firstBatchSize
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "batchSize", () => firstBatchSize.Value, firstBatchSize.HasValue }
};
result.Should().Be(expectedResult);
}
示例10: CreateCommand_should_return_expected_result_when_Hint_is_set
public void CreateCommand_should_return_expected_result_when_Hint_is_set(
[Values(null, "{ hint : 'x_1' }", "{ hint : { x : 1 } }")]
string hintString)
{
var hint = hintString == null ? null : BsonDocument.Parse(hintString)["hint"];
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Hint = hint
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "hint", hint, hint != null }
};
result.Should().Be(expectedResult);
}
示例11: CreateCommand_should_return_expected_result_when_CursorType_is_Set
public void CreateCommand_should_return_expected_result_when_CursorType_is_Set(
[Values(CursorType.NonTailable, CursorType.Tailable, CursorType.TailableAwait)]
CursorType cursorType)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
CursorType = cursorType
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "tailable", true, cursorType == CursorType.Tailable || cursorType == CursorType.TailableAwait },
{ "awaitData", true, cursorType == CursorType.TailableAwait }
};
result.Should().Be(expectedResult);
}
示例12: CreateCommand_should_return_expected_result_when_Comment_is_set
public void CreateCommand_should_return_expected_result_when_Comment_is_set(
[Values(null, "a", "b")]
string comment)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Comment = comment
};
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "comment", () => comment, comment != null }
};
result.Should().Be(expectedResult);
}
示例13: CreateCommand_should_return_expected_result_when_Collation_is_set
public void CreateCommand_should_return_expected_result_when_Collation_is_set(
[Values(null, "en_US", "fr_CA")]
string locale)
{
var collation = locale == null ? null : new Collation(locale);
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
Collation = collation
};
var result = subject.CreateCommand(Feature.Collation.FirstSupportedVersion, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "collation", () => collation.ToBsonDocument(), collation != null }
};
result.Should().Be(expectedResult);
}
示例14: CreateCommand_should_return_expected_result_when_AllowPartialResults_is_set
public void CreateCommand_should_return_expected_result_when_AllowPartialResults_is_set(
[Values(null, false, true)]
bool? allowPartialResults,
[Values(ServerType.Standalone, ServerType.ShardRouter)]
ServerType serverType)
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings)
{
AllowPartialResults = allowPartialResults
};
var result = subject.CreateCommand(null, serverType);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName },
{ "allowPartialResults", () => allowPartialResults.Value, allowPartialResults.HasValue && serverType == ServerType.ShardRouter }
};
result.Should().Be(expectedResult);
}
示例15: CreateCommand_should_return_expected_result
public void CreateCommand_should_return_expected_result()
{
var subject = new FindCommandOperation<BsonDocument>(_collectionNamespace, BsonDocumentSerializer.Instance, _messageEncoderSettings);
var result = subject.CreateCommand(null, 0);
var expectedResult = new BsonDocument
{
{ "find", _collectionNamespace.CollectionName }
};
result.Should().Be(expectedResult);
}