public void constructor_should_throw_when_database_is_null()
        {
            var options = new ImmutableGridFSBucketOptions();

            Action action = () => new GridFSBucket(null, options);

            action.ShouldThrow<ArgumentNullException>().And.ParamName.Should().Be("database");
        }
        public void constructor_should_initialize_instance()
        {
            var database = Substitute.For<IMongoDatabase>();
            var options = new ImmutableGridFSBucketOptions();

            var result = new GridFSBucket(database, options);

            result.Database.Should().BeSameAs(database);
            result.Options.Should().BeSameAs(options);
        }
Beispiel #3
0
        public void ReadPreference_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions {
                ReadPreference = ReadPreference.Secondary
            });

            var result = subject.ReadPreference;

            result.Should().Be(ReadPreference.Secondary);
        }
Beispiel #4
0
        public void SuppressEnsureIndexes_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions {
                SuppressEnsureIndexes = true
            });

            var result = subject.SuppressEnsureIndexes;

            result.Should().BeTrue();
        }
Beispiel #5
0
        public void ChunkSizeBytes_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions {
                ChunkSizeBytes = 123
            });

            var result = subject.ChunkSizeBytes;

            result.Should().Be(123);
        }
Beispiel #6
0
        public void ReadConcern_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions {
                ReadConcern = ReadConcern.Majority
            });

            var result = subject.ReadConcern;

            result.Should().Be(ReadConcern.Majority);
        }
Beispiel #7
0
        public void WriteConcern_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions {
                WriteConcern = WriteConcern.WMajority
            });

            var result = subject.WriteConcern;

            result.Should().Be(WriteConcern.WMajority);
        }
Beispiel #8
0
        public void BucketName_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions {
                BucketName = "bucket"
            });

            var result = subject.BucketName;

            result.Should().Be("bucket");
        }
        public void DisableMD5_get_and_set_should_return_expected_result(
            [Values(false, true)] bool disabled)
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions {
                DisableMD5 = disabled
            });

            var result = subject.DisableMD5;

            result.Should().Be(disabled);
        }
Beispiel #10
0
        public void constructor_with_arguments_should_initialize_instance()
        {
            var mutable = new GridFSBucketOptions {
                BucketName = "bucket", ChunkSizeBytes = 123, ReadPreference = ReadPreference.Secondary, WriteConcern = WriteConcern.WMajority
            };

            var result = new ImmutableGridFSBucketOptions(mutable);

            result.BucketName.Should().Be("bucket");
            result.ChunkSizeBytes.Should().Be(123);
            result.ReadPreference.Should().Be(ReadPreference.Secondary);
            result.WriteConcern.Should().Be(WriteConcern.WMajority);
        }
Beispiel #11
0
        public void constructor_with_immutable_other_should_initialize_instance()
        {
            var mutable = new GridFSBucketOptions {
                BucketName = "bucket", ChunkSizeBytes = 123, ReadPreference = ReadPreference.Secondary, WriteConcern = WriteConcern.WMajority
            };
            var other = new ImmutableGridFSBucketOptions(mutable);

            var result = new GridFSBucketOptions(other);

            result.BucketName.Should().Be(other.BucketName);
            result.ChunkSizeBytes.Should().Be(other.ChunkSizeBytes);
            result.ReadPreference.Should().Be(other.ReadPreference);
            result.WriteConcern.Should().Be(other.WriteConcern);
        }
        public void ReadConcern_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions { ReadConcern = ReadConcern.Majority });

            var result = subject.ReadConcern;

            result.Should().Be(ReadConcern.Majority);
        }
        public void WriteConcern_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions { WriteConcern = WriteConcern.WMajority });

            var result = subject.WriteConcern;

            result.Should().Be(WriteConcern.WMajority);
        }
        // private methods
        private GridFSBucket CreateSubject(ImmutableGridFSBucketOptions options = null)
        {
            var cluster = Substitute.For<ICluster>();

            var client = Substitute.For<IMongoClient>();
            client.Cluster.Returns(cluster);

            var database = Substitute.For<IMongoDatabase>();
            database.Client.Returns(client);

            return new GridFSBucket(database, options);
        }
        public void constructor_with_arguments_should_initialize_instance()
        {
            var mutable = new GridFSBucketOptions { BucketName = "bucket", ChunkSizeBytes = 123, ReadConcern = ReadConcern.Majority, ReadPreference = ReadPreference.Secondary, WriteConcern = WriteConcern.WMajority };

            var result = new ImmutableGridFSBucketOptions(mutable);

            result.BucketName.Should().Be("bucket");
            result.ChunkSizeBytes.Should().Be(123);
            result.ReadConcern.Should().Be(ReadConcern.Majority);
            result.ReadPreference.Should().Be(ReadPreference.Secondary);
            result.WriteConcern.Should().Be(WriteConcern.WMajority);
        }
        public void ChunkSizeBytes_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions { ChunkSizeBytes = 123 });

            var result = subject.ChunkSizeBytes;

            result.Should().Be(123);
        }
        public void BucketName_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions { BucketName = "bucket" });

            var result = subject.BucketName;

            result.Should().Be("bucket");
        }
        public void constructor_with_immutable_other_should_initialize_instance()
        {
            var mutable = new GridFSBucketOptions { BucketName = "bucket", ChunkSizeBytes = 123, ReadConcern = ReadConcern.Majority, ReadPreference = ReadPreference.Secondary, WriteConcern = WriteConcern.WMajority };
            var other = new ImmutableGridFSBucketOptions(mutable);

            var result = new GridFSBucketOptions(other);

            result.BucketName.Should().Be(other.BucketName);
            result.ChunkSizeBytes.Should().Be(other.ChunkSizeBytes);
            result.ReadConcern.Should().Be(other.ReadConcern);
            result.ReadPreference.Should().Be(other.ReadPreference);
            result.WriteConcern.Should().Be(other.WriteConcern);
        }
        public void ReadPreference_get_should_return_expected_result()
        {
            var subject = new ImmutableGridFSBucketOptions(new GridFSBucketOptions { ReadPreference = ReadPreference.Secondary });

            var result = subject.ReadPreference;

            result.Should().Be(ReadPreference.Secondary);
        }
        public void Options_get_should_return_the_expected_result()
        {
            var database = Substitute.For<IMongoDatabase>();
            var options = new ImmutableGridFSBucketOptions();
            var subject = new GridFSBucket(database, options);

            var result = subject.Options;

            result.Should().BeSameAs(options);
        }