public void TestAllValuesGoBackToTheirDefaults()
        {
            var classMap = new BsonClassMap <TestClass>(cm =>
            {
                cm.SetCreator(() => { throw new Exception("will get reset."); });
                cm.MapMember(x => x.String);
                cm.SetDiscriminator("blah");
                cm.SetDiscriminatorIsRequired(true);
                cm.MapExtraElementsMember(x => x.ExtraElements);
                cm.MapIdMember(x => x.OId);
                cm.SetIgnoreExtraElements(false);
                cm.SetIgnoreExtraElementsIsInherited(true);
                cm.SetIsRootClass(true);
                cm.AddKnownType(typeof(InheritedTestClass));
            });

            classMap.Reset();

            classMap.Freeze();

            Assert.DoesNotThrow(() => classMap.CreateInstance());
            Assert.AreEqual(0, classMap.DeclaredMemberMaps.Count());
            Assert.AreEqual("TestClass", classMap.Discriminator);
            Assert.IsFalse(classMap.DiscriminatorIsRequired);
            Assert.IsNull(classMap.ExtraElementsMemberMap);
            Assert.IsNull(classMap.IdMemberMap);
            Assert.IsTrue(classMap.IgnoreExtraElements);
            Assert.IsFalse(classMap.IgnoreExtraElementsIsInherited);
            Assert.IsFalse(classMap.IsRootClass);
            Assert.AreEqual(0, classMap.KnownTypes.Count());
        }
        public void TestSetCreator()
        {
            var classMap = new BsonClassMap <B>(cm =>
            {
                cm.AutoMap();
                cm.SetCreator(() => new B(10));
            });

            classMap.Freeze();

            var instance = (B)classMap.CreateInstance();

            Assert.AreEqual(10, instance.A);
        }
        public void TestSetCreator()
        {
            var classMap = new BsonClassMap<B>(cm =>
            {
                cm.AutoMap();
                cm.SetCreator(() => new B(10));
            });

            classMap.Freeze();

            var instance = (B)classMap.CreateInstance();
            Assert.AreEqual(10, instance.A);
        }
        public void TestAllValuesGoBackToTheirDefaults()
        {
            var classMap = new BsonClassMap<TestClass>(cm =>
            {
                cm.SetCreator(() => { throw new Exception("will get reset."); });
                cm.MapMember(x => x.String);
                cm.SetDiscriminator("blah");
                cm.SetDiscriminatorIsRequired(true);
                cm.MapExtraElementsMember(x => x.ExtraElements);
                cm.MapIdMember(x => x.OId);
                cm.SetIgnoreExtraElements(false);
                cm.SetIgnoreExtraElementsIsInherited(true);
                cm.SetIsRootClass(true);
                cm.AddKnownType(typeof(InheritedTestClass));
            });

            classMap.Reset();

            classMap.Freeze();

            Assert.DoesNotThrow(() => classMap.CreateInstance());
            Assert.AreEqual(0, classMap.DeclaredMemberMaps.Count());
            Assert.AreEqual("TestClass", classMap.Discriminator);
            Assert.IsFalse(classMap.DiscriminatorIsRequired);
            Assert.IsNull(classMap.ExtraElementsMemberMap);
            Assert.IsNull(classMap.IdMemberMap);
            Assert.IsTrue(classMap.IgnoreExtraElements);
            Assert.IsFalse(classMap.IgnoreExtraElementsIsInherited);
            Assert.IsFalse(classMap.IsRootClass);
            Assert.AreEqual(0, classMap.KnownTypes.Count());
        }