public void ExactMatch()
 {
     pointcut.Pattern = "System.Object.GetHashCode";
     ExactMatchTests(pointcut);
     pointcut = (AbstractRegularExpressionMethodPointcut)SerializationTestUtils.SerializeAndDeserialize(pointcut);
     ExactMatchTests(pointcut);
 }
        public void Serialization()
        {
            IObjectFactory iof = new XmlObjectFactory(new ReadOnlyXmlTestResource("RegularExpressionSetterTests.xml", GetType()));
            IPerson        p   = (IPerson)iof.GetObject("SerializableSettersAdvised");
            // Interceptor behind regexp advisor
            NopInterceptor nop = (NopInterceptor)iof.GetObject("NopInterceptor");

            Assert.AreEqual(0, nop.Count);

            int newAge = 12;

            // Not advised
            Assert.AreEqual(0, p.GetAge());
            Assert.AreEqual(0, nop.Count);

            // This is proxied
            p.SetAge(newAge);
            Assert.AreEqual(1, nop.Count);
            p.SetAge(newAge);
            Assert.AreEqual(newAge, p.GetAge());
            // Only setter fired
            Assert.AreEqual(2, nop.Count);

            // Serialize and continue...
            p = (IPerson)SerializationTestUtils.SerializeAndDeserialize(p);
            Assert.AreEqual(newAge, p.GetAge());
            // Remembers count, but we need to get a new reference to nop...
            nop = (SerializableNopInterceptor)((IAdvised)p).Advisors[0].Advice;
            Assert.AreEqual(2, nop.Count);
            Assert.AreEqual("SerializableSettersAdvised", p.GetName());
            p.SetAge(newAge + 1);
            Assert.AreEqual(3, nop.Count);
            Assert.AreEqual(newAge + 1, p.GetAge());
        }
 public void ExactMatchWithGenericType()
 {
     pointcut.Pattern = "System.Collections.Generic.List<string>.Add";
     ExactMatchWithGenericTypeTests(pointcut);
     pointcut = (AbstractRegularExpressionMethodPointcut)SerializationTestUtils.SerializeAndDeserialize(pointcut);
     ExactMatchWithGenericTypeTests(pointcut);
 }
        public void Serializability()
        {
            TransactionInterceptor ti = new TransactionInterceptor();

            ti.TransactionAttributes = new NameValueCollection();
            TransactionAttributeSourceAdvisor tas = new TransactionAttributeSourceAdvisor(ti);

            SerializationTestUtils.SerializeAndDeserialize(tas);
        }
        public void Deserialization()
        {
            ITypeFilter deserializedVersion
                = (ITypeFilter)SerializationTestUtils.SerializeAndDeserialize(
                      TrueTypeFilter.True);

            Assert.IsTrue(Object.ReferenceEquals(TrueTypeFilter.True, deserializedVersion),
                          "Singleton instance not being deserialized correctly");
        }
        public void Deserialization()
        {
            ITargetSource deserializedVersion
                = (ITargetSource)SerializationTestUtils.SerializeAndDeserialize(
                      EmptyTargetSource.Empty);

            Assert.IsTrue(Object.ReferenceEquals(EmptyTargetSource.Empty, deserializedVersion),
                          "Singleton instance not being deserialized correctly");
        }
        public void Deserialization()
        {
            IPointcut deserializedVersion
                = (IPointcut)SerializationTestUtils.SerializeAndDeserialize(
                      TruePointcut.True);

            Assert.IsTrue(Object.ReferenceEquals(TruePointcut.True, deserializedVersion),
                          "Singleton instance not being deserialized correctly");
        }
示例#8
0
        private static void CheckSerialization(
            ObjectDefinitionStoreException inex, string expectedName,
            string expectedResourceDescription)
        {
            ObjectDefinitionStoreException outex = (ObjectDefinitionStoreException)
                                                   SerializationTestUtils.SerializeAndDeserialize(inex);

            Assert.AreEqual(expectedName, outex.ObjectName,
                            "The 'ObjectName' property was not serialized / deserialized correctly.");
            Assert.AreEqual(expectedResourceDescription, outex.ResourceDescription,
                            "The 'ResourceDescription' property was not serialized / deserialized correctly.");
        }
示例#9
0
        public void Serialization()
        {
            IDictionary typeAliases = new Hashtable();

            typeAliases.Add("LinkedList", typeof(LinkedList).AssemblyQualifiedName);

            TypeAliasConfigurer typeAliasConfigurer = new TypeAliasConfigurer();

            typeAliasConfigurer.TypeAliases = typeAliases;

            typeAliasConfigurer.Order = 1;

            SerializationTestUtils.SerializeAndDeserialize(typeAliasConfigurer);
        }
        public void Serialization()
        {
            IDictionary resourceHandlers = new Hashtable();

            resourceHandlers.Add("httpsss", typeof(UrlResource));

            ResourceHandlerConfigurer resourceHandlerConfiguer = new ResourceHandlerConfigurer();

            resourceHandlerConfiguer.ResourceHandlers = resourceHandlers;


            resourceHandlerConfiguer.Order = 1;

            SerializationTestUtils.SerializeAndDeserialize(resourceHandlerConfiguer);
        }
示例#11
0
        public void Serialization()
        {
            TypedStringValue value        = new TypedStringValue();
            Type             expectedType = typeof(string);

            value.TargetType = expectedType;
            const string expectedValue = "rilo-kiley";

            value.Value = expectedValue;

            object foo = SerializationTestUtils.SerializeAndDeserialize(value);

            Assert.IsNotNull(foo, "Serialization roundtrip must never result in null.");
            TypedStringValue deser = foo as TypedStringValue;

            Assert.IsNotNull(deser,
                             "Serialization roundtrip yielded the wrong Type of object.");
            Assert.AreEqual(expectedType, deser.TargetType,
                            "Serialization roundtrip yielded the wrong TargetType.");
            Assert.AreEqual(expectedValue, deser.Value,
                            "Serialization roundtrip yielded the wrong Value.");
        }
 public void SerializationWithNoPatternSupplied()
 {
     pointcut = (AbstractRegularExpressionMethodPointcut)SerializationTestUtils.SerializeAndDeserialize(pointcut);
     NoPatternSuppliedTests(pointcut);
 }
        public void TryMatchesAfterSerialization()
        {
            SdkRegularExpressionMethodPointcut initial = new SdkRegularExpressionMethodPointcut();

            initial.Pattern = "Foo";
            SdkRegularExpressionMethodPointcut pcut = (SdkRegularExpressionMethodPointcut)SerializationTestUtils.SerializeAndDeserialize(initial);

            Assert.IsNotNull(pcut, "Deserialized instance must (obviously) not be null.");
            Type type    = GetType();
            bool isMatch = pcut.Matches(type.GetMethod("ForMatchingPurposesOnly"), type);

            Assert.IsFalse(isMatch, "Whoops, should not be matching here at all.");
        }
        public void InstantiationViaSerialization()
        {
            SdkRegularExpressionMethodPointcut initial = new SdkRegularExpressionMethodPointcut();

            initial.Pattern = "Foo";
            SdkRegularExpressionMethodPointcut pcut = (SdkRegularExpressionMethodPointcut)SerializationTestUtils.SerializeAndDeserialize(initial);

            Assert.IsNotNull(pcut, "Deserialized instance must (obviously) not be null.");
            Assert.AreEqual(initial.Pattern, pcut.Pattern, "Pattern property not deserialized correctly.");
        }