diff --git a/source/MongoDB.Tests/MongoDB.Tests.csproj b/source/MongoDB.Tests/MongoDB.Tests.csproj index 4b21942d..0f1cfe25 100644 --- a/source/MongoDB.Tests/MongoDB.Tests.csproj +++ b/source/MongoDB.Tests/MongoDB.Tests.csproj @@ -95,7 +95,7 @@ - + @@ -104,6 +104,7 @@ + diff --git a/source/MongoDB.Tests/UnitTests/Configuration/MongoConfigurationTests.cs b/source/MongoDB.Tests/UnitTests/Configuration/MongoConfigurationTests.cs new file mode 100644 index 00000000..eef4372a --- /dev/null +++ b/source/MongoDB.Tests/UnitTests/Configuration/MongoConfigurationTests.cs @@ -0,0 +1,61 @@ +using System; +using MongoDB.Configuration; +using NUnit.Framework; + +namespace MongoDB.UnitTests.Configuration +{ + [TestFixture] + public class MongoConfigurationTests + { + [Test] + public void IsModifiableByDefault() + { + var config = new MongoConfiguration(); + Assert.IsTrue(config.IsModifiable); + } + + [Test] + public void IsNotModifiableAfterValidate() + { + var config = new MongoConfiguration(); + config.ValidateAndSeal(); + Assert.IsFalse(config.IsModifiable); + } + + [Test] + [ExpectedException(typeof(InvalidOperationException))] + public void CanNotChangeConnectionStringAfterValidate() + { + var config = new MongoConfiguration(); + config.ValidateAndSeal(); + config.ConnectionString = ""; + } + + [Test] + [ExpectedException(typeof(InvalidOperationException))] + public void CanNotChangeMappingStoreAfterValidate() + { + var config = new MongoConfiguration(); + config.ValidateAndSeal(); + config.MappingStore = null; + } + + [Test] + [ExpectedException(typeof(InvalidOperationException))] + public void CanNotChangeReadLocalTimeAfterValidate() + { + var config = new MongoConfiguration(); + config.ValidateAndSeal(); + config.ReadLocalTime = true; + } + + [Test] + [ExpectedException(typeof(InvalidOperationException))] + public void CanNotChangeSerializationFactoryAfterValidate() + { + var config = new MongoConfiguration(); + config.ValidateAndSeal(); + config.SerializationFactory = null; + } + } +} \ No newline at end of file