12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Topten.JsonKit;
- using System.IO;
- using System.Reflection;
- using Xunit;
- namespace TestCases
- {
- [Obfuscation(Exclude = true, ApplyToMembers = true)]
- public class TestExplicitMembersOnly
- {
- class Thing
- {
- public string Apples = "apples";
- }
- [Json(ExplicitMembersOnly = true)]
- class Thing2
- {
- public string Apples = "apples";
- }
- [Json(ExplicitMembersOnly = true)]
- class Thing3
- {
- [Json("apples")]
- public string Apples = "apples";
- }
- [Fact]
- public void TestNonDecoratedClass()
- {
- var thing = new Thing();
- // Save it
- var json = Json.Format(thing);
- // Check the object kinds were written out
- Assert.Contains("\"apples\":", json);
- }
- [Fact]
- public void TestDecoratedEmptyClass()
- {
- var thing = new Thing2();
- // Save it
- var json = Json.Format(thing);
- // Check the object kinds were written out
- Assert.DoesNotContain("\"apples\":", json);
- }
- [Fact]
- public void TestDecoratedNonEmptyClass()
- {
- var thing = new Thing3();
- // Save it
- var json = Json.Format(thing);
- // Check the object kinds were written out
- Assert.Contains("\"apples\":", json);
- }
- }
- }
|