public void can_notify_after_deserialization()
		{
			var original = new FakeDataContractNotifier();

			var serializer = new DataContractSerializer(typeof(FakeDataContractNotifier));
			var stream = new MemoryStream();
			serializer.WriteObject(stream, original);

			stream.Position = 0;
			var deserialized = (FakeDataContractNotifier)serializer.ReadObject(stream);

			deserialized.FakeProperty = "some string value";
		}
Ejemplo n.º 2
0
        public void can_notify_after_deserialization()
        {
            var original = new FakeDataContractNotifier();

            var serializer = new DataContractSerializer(typeof(FakeDataContractNotifier));
            var stream     = new MemoryStream();

            serializer.WriteObject(stream, original);

            stream.Position = 0;
            var deserialized = (FakeDataContractNotifier)serializer.ReadObject(stream);

            deserialized.FakeProperty = "some string value";
        }
		public void can_be_serialized_and_deserialized()
		{
			var original = new FakeDataContractNotifier();
			original.FakeProperty = "some string value";

			var serializer = new DataContractSerializer(typeof(FakeDataContractNotifier));
			var stream = new MemoryStream();
			serializer.WriteObject(stream, original);

			stream.Position = 0;
			var deserialized = (FakeDataContractNotifier)serializer.ReadObject(stream);

			Assert.AreNotSame(original, deserialized);
			Assert.AreEqual(original.FakeProperty, deserialized.FakeProperty);
		}
		public void can_accept_handlers_after_deserialization()
		{
			var original = new FakeDataContractNotifier();

			var serializer = new DataContractSerializer(typeof(FakeDataContractNotifier));
			var stream = new MemoryStream();
			serializer.WriteObject(stream, original);

			stream.Position = 0;
			var deserialized = (FakeDataContractNotifier)serializer.ReadObject(stream);

			int handlerCalls = 0;
			deserialized.PropertyChanged += (o, e) => { handlerCalls++; };
			deserialized.FakeProperty = "some string value";

			Assert.AreEqual(1, handlerCalls);
		}
Ejemplo n.º 5
0
        public void can_be_serialized_and_deserialized()
        {
            var original = new FakeDataContractNotifier();

            original.FakeProperty = "some string value";

            var serializer = new DataContractSerializer(typeof(FakeDataContractNotifier));
            var stream     = new MemoryStream();

            serializer.WriteObject(stream, original);

            stream.Position = 0;
            var deserialized = (FakeDataContractNotifier)serializer.ReadObject(stream);

            original.ShouldNotBeSameAs(deserialized);
            original.FakeProperty.ShouldBe(deserialized.FakeProperty);
        }
Ejemplo n.º 6
0
        public void can_accept_handlers_after_deserialization()
        {
            var original = new FakeDataContractNotifier();

            var serializer = new DataContractSerializer(typeof(FakeDataContractNotifier));
            var stream     = new MemoryStream();

            serializer.WriteObject(stream, original);

            stream.Position = 0;
            var deserialized = (FakeDataContractNotifier)serializer.ReadObject(stream);

            var handlerCalls = 0;

            deserialized.PropertyChanged += (o, e) => { handlerCalls++; };
            deserialized.FakeProperty     = "some string value";

            handlerCalls.ShouldBe(1);
        }