コード例 #1
0
        public void Constructor_with_1_arguments_should_work()
        {
            var exception = new WriteProtocolException("message");

            exception.Message.Should().Be("message");
            exception.InnerException.Should().BeNull();
            exception.Result.Should().BeNull();
        }
コード例 #2
0
        public void Constructor_with_2_arguments_should_work()
        {
            var result    = new BsonDocument("result", 1);
            var exception = new WriteProtocolException("message", result);

            exception.Message.Should().Be("message");
            exception.InnerException.Should().BeNull();
            exception.Result.Equals(result).Should().BeTrue();
        }
コード例 #3
0
        public void Serialization_should_work()
        {
            var result    = new BsonDocument("result", 1);
            var exception = new WriteProtocolException("message", result);

            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, exception);
                stream.Position = 0;
                var rehydrated = (WriteProtocolException)formatter.Deserialize(stream);
                rehydrated.Message.Should().Be("message");
                rehydrated.InnerException.Should().BeNull();
                rehydrated.Result.Equals(result).Should().BeTrue();
            }
        }