Exemplo n.º 1
0
        public void WriteObject_DataContractIgnoringPrivateMember()
        {
            var dcjs = new DataContractJsonSerializer(typeof(PublicContractAboutPrivateClause));

            using (MemoryStream ms = new MemoryStream()) {
                var c = new PublicContractAboutPrivateClause();
                c.PublicFacingMember = "me";
                // SecretPolicyMakerMember is (default) unassigned
                Assert.Throws <SecurityException, FieldAccessException> (delegate {
                    dcjs.WriteObject(ms, c);
                }, "unassigned private member");
            }
        }
Exemplo n.º 2
0
		public void WriteObject_DataContractIgnoringPrivateMember ()
		{
			var dcjs = new DataContractJsonSerializer (typeof (PublicContractAboutPrivateClause));
			using (MemoryStream ms = new MemoryStream ()) {
				var c = new PublicContractAboutPrivateClause ();
				c.PublicFacingMember = "me";
				// SecretPolicyMakerMember is (default) unassigned
				Assert.Throws<SecurityException,FieldAccessException> (delegate {
					dcjs.WriteObject (ms, c);
				}, "unassigned private member");
			}
		}