public void Should_translate_category_correctly(int code, ServerErrorCategory expectedCategory) { var coreError = new Core.Operations.BulkWriteOperationError(0, code, "blah", new BsonDocument()); var subject = BulkWriteError.FromCore(coreError); subject.Category.Should().Be(expectedCategory); }
// constructors internal WriteError(ServerErrorCategory category, int code, string message, BsonDocument details) { _category = category; _code = code; _details = details; _message = message; }
public void ToString_should_return_expected_result( ServerErrorCategory category, int code, string message, string detailsJson, string expectedResult) { var details = detailsJson == null ? null : BsonDocument.Parse(detailsJson); var writeError = new WriteError(category, code, message, details); var result = writeError.ToString(); result.Should().Be(expectedResult); }
/// <summary> /// 从给定的 <see cref="ServerErrorCategory"/> 枚举值创建相应的 <see cref="RepositoryErrorCode"/> 枚举值。 /// </summary> /// <param name="category"><see cref="ServerErrorCategory"/> 枚举值</param> /// <returns> /// 从给定的 <see cref="ServerErrorCategory"/> 枚举值创建的 <see cref="RepositoryErrorCode"/> 枚举值。 /// </returns> public static RepositoryErrorCode FromMongoServerErrorCategory(ServerErrorCategory category) { switch (category) { case ServerErrorCategory.DuplicateKey: return(RepositoryErrorCode.DuplicateKey); case ServerErrorCategory.ExecutionTimeout: return(RepositoryErrorCode.Timeout); default: return(RepositoryErrorCode.Unknown); } }
public void Should_return_correct_error_category(int code, ServerErrorCategory expectedCategory) { var subject = new BulkWriteOperationError(0, code, "something", new BsonDocument()); subject.Category.Should().Be(expectedCategory); }
// constructors internal BulkWriteError(int index, ServerErrorCategory category, int code, string message, BsonDocument details) : base(category, code, message, details) { _index = index; }