示例#1
0
        public void TestWithoutSerializableHandler()
        {
            IDataPortal <SerializationRoot> dataPortal = _testDIContext.CreateDataPortal <SerializationRoot>();

            TestResults.Reinitialise();
            UnitTestContext             context = GetContext();
            SerializationRoot           root    = SerializationRoot.NewSerializationRoot(dataPortal);
            nonSerializableEventHandler handler = new nonSerializableEventHandler();

            handler.Reg(root);
            root.Data = "something";
            context.Assert.AreEqual("1", TestResults.GetResult("PropertyChangedFiredCount"));
            root.Data = "something else";
            context.Assert.AreEqual("2", TestResults.GetResult("PropertyChangedFiredCount"));

            //serialize an object with eventhandling objects that are nonserializable
            root      = root.Clone();
            root.Data = "something new";

            //still at 2 even though we changed the property again
            //when the clone method performs serialization, the nonserializable
            //object containing an event handler for the propertyChanged event
            //is lost
            context.Assert.AreEqual("2", TestResults.GetResult("PropertyChangedFiredCount"));
            context.Assert.Success();
        }
示例#2
0
    public void TestWithoutSerializableHandler()
    {
      Csla.ApplicationContext.GlobalContext.Clear();
      UnitTestContext context = GetContext();
      SerializationRoot root = new SerializationRoot();
      nonSerializableEventHandler handler = new nonSerializableEventHandler();
      handler.Reg(root);
      root.Data = "something";
      context.Assert.AreEqual(1, Csla.ApplicationContext.GlobalContext["PropertyChangedFiredCount"]);
      root.Data = "something else";
      context.Assert.AreEqual(2, Csla.ApplicationContext.GlobalContext["PropertyChangedFiredCount"]);

      //serialize an object with eventhandling objects that are nonserializable
      root = root.Clone();
      root.Data = "something new";

      //still at 2 even though we changed the property again 
      //when the clone method performs serialization, the nonserializable 
      //object containing an event handler for the propertyChanged event
      //is lost
      context.Assert.AreEqual(2, Csla.ApplicationContext.GlobalContext["PropertyChangedFiredCount"]);
      context.Assert.Success();
    }