Esempio n. 1
0
        public void SerializeToStringTest()
        {
            Expression <Func <SecurityDbContext, int, bool> > criteria = (db, obj) => obj < 5;
            CriteriaSerializer criteriaSerializer = new CriteriaSerializer();
            string             serializedString   = criteriaSerializer.Serialize(criteria);
            XElement           nominal            = SerializeTestHelper.CreateBaseCriteriaXElementWithIntObj();

            XElement body = SerializeTestHelper.GetIntegerBinaryExpression("LessThan", "5");

            SerializeTestHelper.SetLambdaBody(nominal, body);

            Assert.AreEqual(nominal.ToString(), serializedString);
        }
Esempio n. 2
0
        public void CriteriaSection_CanBeSerializedAndDeserialized_Using_Serializer()
        {
            CriteriaSerializer serializer = new CriteriaSerializer();

            BreachAgeGeneralCriteriaSection criteria = new BreachAgeGeneralCriteriaSection
            {
                Session                = ComplianceSession.New,
                SessionId              = 2,
                ShowBreachAges         = true,
                ShowOverriddenBreaches = true,
                ShowRuleGroups         = false
            };

            string xml = serializer.Serialize <BreachAgeGeneralCriteriaSection>(criteria);
            BreachAgeGeneralCriteriaSection crit = serializer.Deserialize <BreachAgeGeneralCriteriaSection>(xml);

            Assert.AreEqual(CompactXml("<BreachAgeGeneralCriteriaSection session=\"New\" session-id=\"2\" show-breach-ages=\"true\" show-overridden-breaches=\"true\" show-rule-groups=\"false\" />"), CompactXml(xml));
        }