PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/MongoDB.Driver.Tests/BulkWriteErrorTests.cs

http://github.com/mongodb/mongo-csharp-driver
C# | 43 lines | 26 code | 3 blank | 14 comment | 0 complexity | 697a57d4fa0be6d83353d8da55f36ea2 MD5 | raw file
Possible License(s): Apache-2.0
  1. /* Copyright 2010-present MongoDB Inc.
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. using System;
  16. using System.Collections.Generic;
  17. using System.Linq;
  18. using System.Text;
  19. using System.Threading.Tasks;
  20. using FluentAssertions;
  21. using MongoDB.Bson;
  22. using Xunit;
  23. namespace MongoDB.Driver.Tests
  24. {
  25. public class BulkWriteErrorTests
  26. {
  27. [Theory]
  28. [InlineData(0, ServerErrorCategory.Uncategorized)]
  29. [InlineData(50, ServerErrorCategory.ExecutionTimeout)]
  30. [InlineData(11000, ServerErrorCategory.DuplicateKey)]
  31. [InlineData(11001, ServerErrorCategory.DuplicateKey)]
  32. [InlineData(12582, ServerErrorCategory.DuplicateKey)]
  33. public void Should_translate_category_correctly(int code, ServerErrorCategory expectedCategory)
  34. {
  35. var coreError = new Core.Operations.BulkWriteOperationError(0, code, "blah", new BsonDocument());
  36. var subject = BulkWriteError.FromCore(coreError);
  37. subject.Category.Should().Be(expectedCategory);
  38. }
  39. }
  40. }