예제 #1
0
        public void TestNamedIdMemberConventionWithTestClassB()
        {
            var convention = new NamedIdMemberConvention("Id", "id", "_id");
            var classMap   = new BsonClassMap <TestClassB>();

            convention.Apply(classMap);
            Assert.Null(classMap.IdMemberMap);
        }
        public void TestNamedIdMemberConventionWillNotReturnIdWithoutGetter()
        {
            var convention = new NamedIdMemberConvention("Id", "id", "_id");
            var classMap   = new BsonClassMap <TestClassNoIdGetter>();

            convention.Apply(classMap);
            Assert.Null(classMap.IdMemberMap);
        }
        public void TestNamedIdMemberConventionWithTestClassD()
        {
            var convention = new NamedIdMemberConvention("Id", "id", "_id");
            var classMap   = new BsonClassMap <TestClassD>();

            convention.Apply(classMap);
            Assert.IsNotNull(classMap.IdMemberMap);
            Assert.AreEqual("_id", classMap.IdMemberMap.MemberName);
        }
        public void TestNamedIdMemberConvention()
        {
            var convention = new NamedIdMemberConvention("Id", "id", "_id");

            var idMemberName = convention.FindIdMember(typeof(TestClassA));

            Assert.IsNotNull(idMemberName);
            Assert.AreEqual("Id", idMemberName);

            idMemberName = convention.FindIdMember(typeof(TestClassB));
            Assert.IsNull(idMemberName);

            idMemberName = convention.FindIdMember(typeof(TestClassC));
            Assert.IsNotNull(idMemberName);
            Assert.AreEqual("id", idMemberName);

            idMemberName = convention.FindIdMember(typeof(TestClassD));
            Assert.IsNotNull(idMemberName);
            Assert.AreEqual("_id", idMemberName);
        }
        public void TestNamedIdMemberConvention()
        {
            var convention = new NamedIdMemberConvention("Id", "id", "_id");

#pragma warning disable 618
            var idMemberName = convention.FindIdMember(typeof(TestClassA));
            Assert.IsNotNull(idMemberName);
            Assert.AreEqual("Id", idMemberName);

            idMemberName = convention.FindIdMember(typeof(TestClassB));
            Assert.IsNull(idMemberName);

            idMemberName = convention.FindIdMember(typeof(TestClassC));
            Assert.IsNotNull(idMemberName);
            Assert.AreEqual("id", idMemberName);

            idMemberName = convention.FindIdMember(typeof(TestClassD));
            Assert.IsNotNull(idMemberName);
            Assert.AreEqual("_id", idMemberName);
#pragma warning restore 618
        }
 public NamedIdConventionsTests()
 {
     _subject = new NamedIdMemberConvention(new[] { "One", "Two" });
 }
 public void FixtureSetUp()
 {
     _subject = new NamedIdMemberConvention(new[] { "One", "Two" });
 }