public void CanWriteTypeStack() { Serializer serializer = new Serializer(new[] {"InternalUse"}); Stack<Type> typeStack = new Stack<Type>(); typeStack.Push(typeof (SampleService.CompositeType)); string models = serializer.WriteDefinitions(typeStack); var obj = JObject.Parse(HttpUtility.UrlDecode(models)); Assert.AreEqual(2, obj.Count); Assert.IsNotNull(obj["SampleService.CompositeType"]); }
public void CanHideTaggedTypes() { var typeStack = new Stack<Type>(); typeStack.Push(typeof (ModelSampleA)); typeStack.Push(typeof (ModelSampleB)); //gets the Secret property when it's tag isn't configured var serializerAll = new Serializer(null); string modelAll = serializerAll.WriteDefinitions(typeStack); Assert.IsFalse(string.IsNullOrEmpty(modelAll)); var objAll = JObject.Parse(modelAll) as JObject; Assert.AreEqual(2, objAll.Count); Assert.AreEqual(0, typeStack.Count); var serializerTags = new Serializer(new[] {"Test"}); typeStack.Push(typeof (ModelSampleA)); typeStack.Push(typeof (ModelSampleB)); string modelHidden = serializerTags.WriteDefinitions(typeStack); Assert.IsFalse(string.IsNullOrEmpty(modelHidden)); var objHidden = JObject.Parse(modelHidden) as JObject; Assert.AreEqual(1, objHidden.Count); }