public void ConfigureConnection_SetWrongConnectionSettings_ThrowsExceptionDuringBuild() { // Arrange var mongoDatabaseBuilder = new MongoDatabaseBuilder(_mongoOptions); // Act mongoDatabaseBuilder.ConfigureConnection( settings => settings.HeartbeatInterval = TimeSpan.FromSeconds(-20)); Action buildMongoDbContext = () => mongoDatabaseBuilder.Build(); // Assert Assert.Throws <ArgumentOutOfRangeException>(buildMongoDbContext); }
public void ConfigureConnection_NoSpecificConnectionSettingsSet_DefaultConnectionSettingsSet() { // Arrange var mongoDatabaseBuilder = new MongoDatabaseBuilder(_mongoOptions); // Act mongoDatabaseBuilder .ConfigureConnection(settings => settings.ApplicationName = "Test"); MongoDbContextData result = mongoDatabaseBuilder.Build(); // Assert Assert.Equal(ReadPreference.Primary, result.Client.Settings.ReadPreference); Assert.Equal(ReadConcern.Majority, result.Client.Settings.ReadConcern); Assert.Equal(WriteConcern.WMajority.With(journal: true), result.Client.Settings.WriteConcern); }
public void ConfigureConnection_SetSpecificConnectionSettings_MongoConnectionSettingsSetSuccessfully() { // Arrange var mongoDatabaseBuilder = new MongoDatabaseBuilder(_mongoOptions); // Act mongoDatabaseBuilder .ConfigureConnection(settings => settings.ApplicationName = "Test") .ConfigureConnection(settings => settings.ConnectionMode = ConnectionMode.Direct) .ConfigureConnection(settings => settings.WriteConcern = WriteConcern.W3); MongoDbContextData result = mongoDatabaseBuilder.Build(); // Assert Assert.Equal("Test", result.Client.Settings.ApplicationName); Assert.Equal(ConnectionMode.Direct, result.Client.Settings.ConnectionMode); Assert.Equal(WriteConcern.W3, result.Client.Settings.WriteConcern); }