public void IsSerializable()
        {
            WeakHashtable weakHashtable = new WeakHashtable();

            weakHashtable.Add("key", new object());
            NHAssert.IsSerializable(weakHashtable);
        }
Exemplo n.º 2
0
        public void CanBeSerialized()
        {
            TestsContext.AssumeSystemTypeIsSerializable();
            ClassValidator cv = new ClassValidator(typeof(Address));

            NHAssert.IsSerializable(cv);
        }
Exemplo n.º 3
0
        public void EachEmbeddedBasicTypeIsSerializable()
        {
            var testExplicit = new HashSet <string>
            {
                "Serializable",
                "Object"
            };

            var builtInCustomTypes =
                typeof(NHibernateUtil)
                .GetFields(BindingFlags.Public | BindingFlags.Static)
                .Where(f => !testExplicit.Contains(f.Name));

            foreach (var fieldInfo in builtInCustomTypes)
            {
                var ntp = (IType)fieldInfo.GetValue(null);
                NHAssert.IsSerializable(ntp, fieldInfo.Name + " is not serializable");
            }

            if (typeof(System.Type).IsSerializable)
            {
                NHAssert.IsSerializable(NHibernateUtil.Serializable);
                NHAssert.IsSerializable(NHibernateUtil.Object);
            }
        }
Exemplo n.º 4
0
        public void ProjectionsExpressions()
        {
            IProjection p = Projections.Avg("StudentNumber");

            NHAssert.IsSerializable(p);
            p = Projections.Count("StudentNumber");
            NHAssert.IsSerializable(p);
            p = Projections.CountDistinct("StudentNumber");
            NHAssert.IsSerializable(p);
            p = Projections.GroupProperty("Name");
            NHAssert.IsSerializable(p);
            p = Projections.Id();
            NHAssert.IsSerializable(p);
            p = Projections.Max("StudentNumber");
            NHAssert.IsSerializable(p);
            p = Projections.Min("StudentNumber");
            NHAssert.IsSerializable(p);
            p = Projections.Property("StudentNumber");
            NHAssert.IsSerializable(p);
            p = Projections.RowCount();
            NHAssert.IsSerializable(p);
            p = Projections.Sum("StudentNumber");
            NHAssert.IsSerializable(p);

            p = Projections.Alias(Projections.Count("StudentNumber"), "alias");
            NHAssert.IsSerializable(p);
            p = Projections.Distinct(Projections.Id());
            NHAssert.IsSerializable(p);
            p = Projections.ProjectionList().Add(Projections.Max("StudentNumber"));
            NHAssert.IsSerializable(p);
        }
        public void CanBeSerialized()
        {
            TestsContext.AssumeSystemTypeIsSerializable();
            ValidatorEngine ve = new ValidatorEngine();

            NHAssert.IsSerializable(ve);
        }
        public void DelegatedEntityValidatorAttributeIsSerializable()
        {
            TestsContext.AssumeSystemTypeIsSerializable();
            var attributeInstance = new DelegatedValidatorAttribute(new DelegatedConstraint <Dummy>((i, c) => i.Value > 0));

            NHAssert.IsSerializable(attributeInstance);
        }
Exemplo n.º 7
0
        public void DelegatedConstraintIsSerializable()
        {
            TestsContext.AssumeSystemTypeIsSerializable();
            var validatorInstance = new DelegatedConstraint <Dummy>((i, c) => i.Value > 0);

            NHAssert.IsSerializable(validatorInstance);
        }
Exemplo n.º 8
0
        public void AliasToBeanResultTransformerIsSerializable()
        {
            TestsContext.AssumeSystemTypeIsSerializable();

            var rt = new AliasToBeanResultTransformer(typeof(StudentDTO));

            NHAssert.IsSerializable(rt);
        }
Exemplo n.º 9
0
        public void AliasToBeanConstructorResultTransformerIsSerializable()
        {
            TestsContext.AssumeSystemTypeIsSerializable();

            var rt = new AliasToBeanConstructorResultTransformer(typeof(StudentDTO).GetConstructor(System.Type.EmptyTypes));

            NHAssert.IsSerializable(rt);
        }
 public void EachEmbeddedBasicTypeIsSerializable()
 {
     FieldInfo[] builtInCustomTypes = typeof(NHibernateUtil).GetFields(BindingFlags.Public | BindingFlags.Static);
     foreach (FieldInfo fieldInfo in builtInCustomTypes)
     {
         IType ntp = (IType)fieldInfo.GetValue(null);
         NHAssert.IsSerializable(ntp, fieldInfo.Name + " is not serializable");
     }
 }
Exemplo n.º 11
0
        private void DoTestType(IType type, object value)
        {
            var session = Substitute.For <ISessionImplementor>();
            var cached  = type.Disassemble(value, session, null);

            // All NHibernate types should yield a cacheable representation that are at least binary serializable
            NHAssert.IsSerializable(cached);
            var reassembled = type.Assemble(cached, session, null);

            Assert.That(type.IsEqual(reassembled, value), Is.True);
        }
Exemplo n.º 12
0
        public void LogicalCriterions()
        {
            ICriterion c =
                Expression.Or(Expression.Eq("Name", "Ralph"), Expression.Eq("Name", "Gavin"));

            NHAssert.IsSerializable(c);
            c =
                Expression.And(Expression.Gt("StudentNumber", 1),
                               Expression.Lt("StudentNumber", 10));
            NHAssert.IsSerializable(c);
        }
        public void LazyFieldInterceptorIsBinarySerializable()
        {
            var pf           = new DefaultProxyFactory();
            var propertyInfo = typeof(MyClass).GetProperty("Id");

            pf.PostInstantiate("MyClass", typeof(MyClass), new HashSet <System.Type>(), propertyInfo.GetGetMethod(), propertyInfo.GetSetMethod(), null);
            var fieldInterceptionProxy = (IFieldInterceptorAccessor)pf.GetFieldInterceptionProxy(new MyClass());

            fieldInterceptionProxy.FieldInterceptor = new DefaultFieldInterceptor(null, null, null, "MyClass", typeof(MyClass));

            NHAssert.IsSerializable(fieldInterceptionProxy);
        }
Exemplo n.º 14
0
        public void LikeCriterions()
        {
            ICriterion c = Expression.Like("Name", "Gavin", MatchMode.Anywhere);

            NHAssert.IsSerializable(c);
            c = Expression.Like("Name", "Gavin", MatchMode.End);
            NHAssert.IsSerializable(c);
            c = Expression.Like("Name", "Gavin", MatchMode.Exact);
            NHAssert.IsSerializable(c);
            c = Expression.Like("Name", "Gavin", MatchMode.Start);
            NHAssert.IsSerializable(c);
        }
Exemplo n.º 15
0
        public void Junctions()
        {
            ICriterion c = Expression.Conjunction()
                           .Add(Expression.Eq("Name", "Ralph"))
                           .Add(Expression.Eq("StudentNumber", "1"));

            NHAssert.IsSerializable(c);
            c = Expression.Disjunction()
                .Add(Expression.Eq("Name", "Ralph"))
                .Add(Expression.Eq("Name", "Gavin"));
            NHAssert.IsSerializable(c);
        }
Exemplo n.º 16
0
        public void AllValidatorsCanBeSerialized()
        {
            TestsContext.AssumeSystemTypeIsSerializable();
            // Test that can be serialized after creation and test default constructor
            var implementors = GetValidatorImplementors();

            foreach (var implementor in implementors)
            {
                object validatorInstance = Activator.CreateInstance(implementor);
                NHAssert.IsSerializable(validatorInstance);
            }
        }
Exemplo n.º 17
0
        public void ResultTransformesAreSerializable()
        {
            IResultTransformer rt = new RootEntityResultTransformer();

            NHAssert.IsSerializable(rt);

            rt = new DistinctRootEntityResultTransformer();
            NHAssert.IsSerializable(rt);

            rt = new PassThroughResultTransformer();
            NHAssert.IsSerializable(rt);
        }
Exemplo n.º 18
0
        public void SQLProjection()
        {
            IProjection p = Projections.SqlProjection("COUNT(*)",
                                                      new string[] { "tStudent" }, new IType[] { NHibernateUtil.Int32 });

            NHAssert.IsSerializable(p);
            p =
                Projections.SqlGroupProjection("COUNT({alias}.studentId), {alias}.preferredCourseCode",
                                               "{alias}.preferredCourseCode",
                                               new string[] { "studentsOfCourse", "CourseCode" },
                                               new IType[] { NHibernateUtil.Int32, NHibernateUtil.Int32 });
            NHAssert.IsSerializable(p);
        }
Exemplo n.º 19
0
        public void BasicCriterions()
        {
            ICriterion c = Expression.Eq("Name", "Gavin King");

            NHAssert.IsSerializable(c);
            IDictionary nameValue = new Hashtable(1);

            nameValue.Add("Name", "Ralph");
            c = Expression.AllEq(nameValue);
            NHAssert.IsSerializable(c);
            c = Expression.Between("Name", "aaaaa", "zzzzz");
            NHAssert.IsSerializable(c);
            c = Expression.EqProperty("Name", "Name");
            NHAssert.IsSerializable(c);
            c = Expression.Ge("Name", "a");
            NHAssert.IsSerializable(c);
            c = Expression.GeProperty("Name", "Name");
            NHAssert.IsSerializable(c);
            c = Expression.Gt("Name", "z");
            NHAssert.IsSerializable(c);
            c = Expression.GtProperty("Name", "Name");
            NHAssert.IsSerializable(c);
            c = Expression.IdEq(1);
            NHAssert.IsSerializable(c);
            c = Expression.In("Name", new string[] { "Gavin", "Ralph" });
            NHAssert.IsSerializable(c);
            c = Expression.InsensitiveLike("Name", "GAVIN");
            NHAssert.IsSerializable(c);
            c = Expression.IsEmpty("Enrolments");
            NHAssert.IsSerializable(c);
            c = Expression.IsNotEmpty("Enrolments");
            NHAssert.IsSerializable(c);
            c = Expression.IsNotNull("PreferredCourse");
            NHAssert.IsSerializable(c);
            c = Expression.IsNull("PreferredCourse");
            NHAssert.IsSerializable(c);
            c = Expression.Le("Name", "a");
            NHAssert.IsSerializable(c);
            c = Expression.LeProperty("Name", "Name");
            NHAssert.IsSerializable(c);
            c = Expression.Lt("Name", "z");
            NHAssert.IsSerializable(c);
            c = Expression.LtProperty("Name", "Name");
            NHAssert.IsSerializable(c);
            c = Expression.Like("Name", "G%");
            NHAssert.IsSerializable(c);
            c = Expression.Not(Expression.Eq("Name", "Ralph"));
            NHAssert.IsSerializable(c);
            c = Expression.NotEqProperty("Name", "Name");
            NHAssert.IsSerializable(c);
        }
Exemplo n.º 20
0
        public void ResultTransformes()
        {
            IResultTransformer rt = new RootEntityResultTransformer();

            NHAssert.IsSerializable(rt);

            rt = new AliasToBeanConstructorResultTransformer(typeof(StudentDTO).GetConstructor(System.Type.EmptyTypes));
            NHAssert.IsSerializable(rt);

            rt = new AliasToBeanResultTransformer(typeof(StudentDTO));
            NHAssert.IsSerializable(rt);

            rt = new DistinctRootEntityResultTransformer();
            NHAssert.IsSerializable(rt);

            rt = new PassThroughResultTransformer();
            NHAssert.IsSerializable(rt);
        }
 public void IsSerializable()
 {
     NHAssert.IsSerializable(new PropertyNotFoundException(null, "someField"));
     NHAssert.IsSerializable(new PropertyNotFoundException(null, "SomeProperty", "getter"));
 }
Exemplo n.º 22
0
        public void SQLCriterion()
        {
            ICriterion c = Expression.Sql("SELECT Name FROM Student");

            NHAssert.IsSerializable(c);
        }
Exemplo n.º 23
0
        public void SubqueriesExpressions()
        {
            DetachedCriteria dc = DetachedCriteria.For(typeof(Student))
                                  .Add(Expression.Eq("Name", "Gavin King"));
            ICriterion c = Subqueries.Eq("Gavin King", dc);

            NHAssert.IsSerializable(c);
            c = Subqueries.EqAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Exists(dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Ge("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GeAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GeSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Gt("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GtAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.GtSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.In("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Le("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LeAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LeSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Lt("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LtAll("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.LtSome("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.Ne("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.NotExists(dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.NotIn("Gavin King", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyEq("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyEqAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGe("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGeAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGeSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGt("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGtAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyGtSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyIn("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLe("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLeAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLeSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLt("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLtAll("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyLtSome("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyNe("Name", dc);
            NHAssert.IsSerializable(c);
            c = Subqueries.PropertyNotIn("Name", dc);
            NHAssert.IsSerializable(c);
        }
Exemplo n.º 24
0
        public void AliasToBeanResultTransformerIsSerializable()
        {
            var rt = new AliasToBeanResultTransformer(typeof(StudentDTO));

            NHAssert.IsSerializable(rt);
        }
 public void AllEventsCanBeSerialized()
 {
     NHAssert.IsSerializable(new ValidatePreInsertEventListener());
     NHAssert.IsSerializable(new ValidatePreUpdateEventListener());
 }