コード例 #1
0
        public void NonSerializableObjectIsSerializable()
        {
            var  self   = new NonSerializableObject();
            bool actual = self.IsSerializable();

            Assert.IsFalse(actual);
        }
コード例 #2
0
        public void TryGetFromFileFailure()
        {
            NonSerializableObject result = null;

            notXml.WriteToFile(path);
            var actual = Deserializer <NonSerializableObject> .TryGetInstanceFromFile(path, ref result, "http://pragma.no/Pragma.Core.CrossCuttingTest.Mock.NonSerializableObject");

            Assert.IsNull(result);
            Assert.IsFalse(actual);
        }
コード例 #3
0
        public void SerializeUnsafeObjectSuccess()
        {
            var self = new NonSerializableObject();

            self.AString = "test";
            self.AnInt   = 12;
            var actual = self.Serialize("http://unsafe.com/", true);

            Assert.IsTrue(actual.Contains("test"));
            Assert.IsTrue(actual.Contains("http://unsafe.com/"));
        }
コード例 #4
0
        public void DeserializeTest()
        {
            var actual = Deserializer <NonSerializableObject> .Deserialize(xml, "http://pragma.no/Pragma.Core.CrossCuttingTest.Mock.NonSerializableObject");

            NonSerializableObject expected = new NonSerializableObject()
            {
                AnInt = 12, AString = "test"
            };

            Assert.AreEqual(expected.AString, actual.AString);
            Assert.AreEqual(expected.AnInt, actual.AnInt);
        }
コード例 #5
0
        public void SerializeSafeObjectToFile()
        {
            var self = new NonSerializableObject();

            self.AString = "test";
            self.AnInt   = 12;
            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }
            self.SerializeToFile(filePath, true);
            Assert.IsTrue(File.Exists(filePath));
        }
コード例 #6
0
        public async Task DuplexObservableWithNonSerializablePayload()
        {
            var service = TestService.Create(TestService.UnrestrictedOptions, new[] { typeof(NonSerializableObject) }, Observable.Return(new TestContext()));

            var obj   = new NonSerializableObject();
            var local = Observable.Return(obj);

            var results = await service.QueryAsync(source => from context in source
                                                   from value in local
                                                   select value);

            QactiveAssert.AreEqual(results, OnNext(obj), OnCompleted <NonSerializableObject>());
        }
コード例 #7
0
        public void TryGetFromFileSuccess()
        {
            xml.WriteToFile(path);
            NonSerializableObject result   = null;
            NonSerializableObject expected = new NonSerializableObject()
            {
                AnInt = 12, AString = "test"
            };
            var actual = Deserializer <NonSerializableObject> .TryGetInstanceFromFile(path, ref result, "http://pragma.no/Pragma.Core.CrossCuttingTest.Mock.NonSerializableObject");

            Assert.IsNotNull(result);
            Assert.AreEqual(expected.AString, result.AString);
            Assert.AreEqual(expected.AnInt, result.AnInt);
            Assert.IsTrue(actual);
        }
コード例 #8
0
        public void SerializeUnsafeObjectFails()
        {
            var self = new NonSerializableObject();

            self.AString = "test";
            self.AnInt   = 12;
            string actual = null;

            try
            {
                actual = self.Serialize("http://unsafe.com/");
                Assert.Fail();
            }
            catch
            {
                Assert.AreEqual(null, actual);
            }
        }
コード例 #9
0
 public void TryGetNonSerializable(string domainName)
 {
     if (_childProxies.ContainsKey(domainName))
     {
         try
         {
             NonSerializableObject s = _childProxies[domainName].GetNonSerializableObject();
             Console.WriteLine("Not possible to get here");
         }
         catch (Exception ex)
         {
             Console.WriteLine("You get an exception from {0}", domainName);
             Console.WriteLine(ex);
         }
     }
     else
     {
         Console.WriteLine("Child domain {0} does not exist", domainName);
     }
 }
コード例 #10
0
 public void ThreadAffinitizedDataObject(NonSerializableObject o)
 {
     Assert.Equal(System.Diagnostics.Process.GetCurrentProcess().Id, o.ProcessId);
     Assert.Equal(Environment.CurrentManagedThreadId, o.ThreadId);
 }
コード例 #11
0
        /// <summary>
        /// Common Test code to try and serialize a non serializable object
        /// </summary>
        /// <param name="provider">
        /// The provider to use to perform the serialization
        /// </param>
        public static void Serialize_NonSerializableObject(SerializationProvider provider)
        {
            NonSerializableObject obj1 = new NonSerializableObject();

            provider.Serialize(obj1);
        }
コード例 #12
0
 public ChildProxy()
 {
     _referencedObject = new ReferencedObject();
     _serializableObject = new SerializableObject();
     _nonSerializableObject = new NonSerializableObject();
 }
コード例 #13
0
ファイル: XmlSerializerTests.cs プロジェクト: OpenSharp/mono
        public void Serialize_NonSerializableObject_error()
        {
            var serializer = new XmlSerializer(typeof(NonSerializableObject));
            var o = new NonSerializableObject("any");
            var m = new MemoryStream();

            serializer.Serialize(m,o);
        }
コード例 #14
0
 public ChildProxy()
 {
     _referencedObject      = new ReferencedObject();
     _serializableObject    = new SerializableObject();
     _nonSerializableObject = new NonSerializableObject();
 }
コード例 #15
0
 public NonSerializableAttribute(int arg1, int arg2)
 {
     prop1 = arg1;
     prop2 = new NonSerializableObject(arg1);
 }