PageRenderTime 30ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/src/MongoDB.Driver.Core.Tests/MongoWaitQueueFullExceptionTests.cs

http://github.com/mongodb/mongo-csharp-driver
C# | 70 lines | 46 code | 10 blank | 14 comment | 0 complexity | 5b215ce384b68de26330937dc84360ed MD5 | raw file
Possible License(s): Apache-2.0
  1. /* Copyright 2013-2014 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.IO;
  16. using System.Net;
  17. using System.Runtime.Serialization.Formatters.Binary;
  18. using FluentAssertions;
  19. using NUnit.Framework;
  20. namespace MongoDB.Driver
  21. {
  22. [TestFixture]
  23. public class MongoWaitQueueFullExceptionTests
  24. {
  25. [Test]
  26. public void constructor_should_initalize_subject()
  27. {
  28. var subject = new MongoWaitQueueFullException("message");
  29. subject.Message.Should().Be("message");
  30. subject.InnerException.Should().BeNull();
  31. }
  32. [Test]
  33. public void ForConnectionPool_should_create_expected_message()
  34. {
  35. var endPoint = new DnsEndPoint("localhost", 27017);
  36. var subject = MongoWaitQueueFullException.ForConnectionPool(endPoint);
  37. subject.Message.Should().Be("The wait queue for acquiring a connection to server localhost:27017 is full.");
  38. }
  39. [Test]
  40. public void ForServerSelection_should_create_expected_message()
  41. {
  42. var subject = MongoWaitQueueFullException.ForServerSelection();
  43. subject.Message.Should().Be("The wait queue for server selection is full.");
  44. }
  45. [Test]
  46. public void Serialization_should_work()
  47. {
  48. var subject = new MongoWaitQueueFullException("message");
  49. var formatter = new BinaryFormatter();
  50. using (var stream = new MemoryStream())
  51. {
  52. formatter.Serialize(stream, subject);
  53. stream.Position = 0;
  54. var rehydrated = (MongoWaitQueueFullException)formatter.Deserialize(stream);
  55. rehydrated.Message.Should().Be(subject.Message);
  56. rehydrated.InnerException.Should().BeNull();
  57. }
  58. }
  59. }
  60. }