public void TestLookupIdGeneratorConvention()
        {
            var convention = new LookupIdGeneratorConvention();

            var guidProperty     = typeof(TestClass).GetProperty("GuidId");
            var objectIdProperty = typeof(TestClass).GetProperty("ObjectId");

            Assert.IsInstanceOf <GuidGenerator>(convention.GetIdGenerator(guidProperty));
            Assert.IsInstanceOf <ObjectIdGenerator>(convention.GetIdGenerator(objectIdProperty));
        }
Exemplo n.º 2
0
        public void TestLookupIdGeneratorConventionWithTestClassB()
        {
            var convention = new LookupIdGeneratorConvention();
            var classMap   = new BsonClassMap <TestClassB>();

            classMap.MapIdMember(x => x.GuidId);
            convention.PostProcess(classMap);
            Assert.NotNull(classMap.IdMemberMap.IdGenerator);
            Assert.IsType <GuidGenerator>(classMap.IdMemberMap.IdGenerator);
        }
        public void TestLookupIdGeneratorConventionWithTestClassA()
        {
            var convention = new LookupIdGeneratorConvention();
            var classMap   = new BsonClassMap <TestClassA>();

            classMap.MapIdMember(x => x.ObjectId);
            convention.PostProcess(classMap);
            Assert.IsNotNull(classMap.IdMemberMap.IdGenerator);
            Assert.IsInstanceOf <ObjectIdGenerator>(classMap.IdMemberMap.IdGenerator);
        }