public void TestAll()
        {
            var server   = MongoServer.Create();
            var settings = new MongoDatabaseSettings(server, "database")
            {
                Credentials = MongoCredentials.Create("username", "password"),
                SafeMode    = SafeMode.Create(5, TimeSpan.FromSeconds(5)),
                SlaveOk     = true
            };

            Assert.AreEqual("database", settings.DatabaseName);
            Assert.AreEqual(MongoCredentials.Create("username", "password"), settings.Credentials);
            Assert.AreEqual(GuidRepresentation.CSharpLegacy, settings.GuidRepresentation);
            Assert.AreEqual(SafeMode.Create(5, TimeSpan.FromSeconds(5)), settings.SafeMode);
            Assert.AreEqual(true, settings.SlaveOk);

            Assert.IsFalse(settings.IsFrozen);
            var hashCode             = settings.GetHashCode();
            var stringRepresentation = settings.ToString();

            Assert.AreEqual(settings, settings);

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());
        }
예제 #2
0
        public void TestFreeze()
        {
            var settings = new MongoDatabaseSettings
            {
                WriteConcern = new WriteConcern()
            };

            Assert.False(settings.IsFrozen);
            var hashCode             = settings.GetHashCode();
            var stringRepresentation = settings.ToString();

            settings.Freeze();
            Assert.True(settings.IsFrozen);
            Assert.Equal(hashCode, settings.GetHashCode());
            Assert.Equal(stringRepresentation, settings.ToString());
        }
예제 #3
0
        public void TestFeeze()
        {
            var settings = new MongoDatabaseSettings
            {
                ReadPreference = new ReadPreference(),
                WriteConcern   = new WriteConcern()
            };

            Assert.IsFalse(settings.IsFrozen);
            Assert.IsFalse(settings.ReadPreference.IsFrozen);
            Assert.IsFalse(settings.WriteConcern.IsFrozen);
            var hashCode             = settings.GetHashCode();
            var stringRepresentation = settings.ToString();

            settings.Freeze();
            Assert.IsTrue(settings.IsFrozen);
            Assert.IsTrue(settings.ReadPreference.IsFrozen);
            Assert.IsTrue(settings.WriteConcern.IsFrozen);
            Assert.AreEqual(hashCode, settings.GetHashCode());
            Assert.AreEqual(stringRepresentation, settings.ToString());
        }