public void TestAll() { var settings = new MongoCollectionSettings <BsonDocument>( "collection", true, // asssignIdOnInsert SafeMode.Create(5, TimeSpan.FromSeconds(5)), true // slaveOkd ); Assert.AreEqual("collection", settings.CollectionName); Assert.AreEqual(true, settings.AssignIdOnInsert); Assert.AreEqual(typeof(BsonDocument), settings.DefaultDocumentType); 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()); }
public void TestAll() { var server = MongoServer.Create(); var database = server["test"]; var settings = new MongoCollectionSettings <BsonDocument>(database, "collection") { AssignIdOnInsert = true, SafeMode = SafeMode.Create(5, TimeSpan.FromSeconds(5)), SlaveOk = true }; Assert.AreEqual("collection", settings.CollectionName); Assert.AreEqual(true, settings.AssignIdOnInsert); Assert.AreEqual(typeof(BsonDocument), settings.DefaultDocumentType); 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()); }
public void TestFeeze() { var settings = new MongoCollectionSettings(); 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()); }
public void TestFeeze() { var settings = new MongoCollectionSettings <BsonDocument>(_database, "collection") { 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()); }