Ejemplo n.º 1
0
        public void constructor_should_initialize_subject()
        {
            var subject = new MongoNotPrimaryException(_connectionId, _serverResult);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeNull();
            subject.Message.Should().Be("Server returned not master error.");
            subject.Result.Should().Be(_serverResult);
        }
Ejemplo n.º 2
0
        public void constructor_should_initialize_subject()
        {
            var subject = new MongoNotPrimaryException(_connectionId, _serverResult);

            subject.ConnectionId.Should().BeSameAs(_connectionId);
            subject.InnerException.Should().BeNull();
            subject.Message.Should().Be("Server returned not master error.");
            subject.Result.Should().Be(_serverResult);
        }
Ejemplo n.º 3
0
        public void Serialization_should_work()
        {
            var subject = new MongoNotPrimaryException(_connectionId, _serverResult);

            var formatter = new BinaryFormatter();
            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoNotPrimaryException)formatter.Deserialize(stream);

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.InnerException.Should().BeNull();
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.Result.Should().Be(subject.Result);
            }
        }
Ejemplo n.º 4
0
        public void Serialization_should_work()
        {
            var subject = new MongoNotPrimaryException(_connectionId, _serverResult);

            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                formatter.Serialize(stream, subject);
                stream.Position = 0;
                var rehydrated = (MongoNotPrimaryException)formatter.Deserialize(stream);

                rehydrated.ConnectionId.Should().Be(subject.ConnectionId);
                rehydrated.InnerException.Should().BeNull();
                rehydrated.Message.Should().Be(subject.Message);
                rehydrated.Result.Should().Be(subject.Result);
            }
        }