public void DepthChecks()
        {
            var writer = new FudgeJSONStreamWriter(context, new StringWriter());

            Assert.Throws<InvalidOperationException>(() => writer.StartSubMessage("test", null));
            Assert.Throws<InvalidOperationException>(() => writer.WriteField("test", null, null, "test"));
            Assert.Throws<InvalidOperationException>(() => writer.EndSubMessage());
            Assert.Throws<InvalidOperationException>(() => writer.EndMessage());

            writer.StartMessage();
            Assert.Throws<InvalidOperationException>(() => writer.StartMessage());
            Assert.Throws<InvalidOperationException>(() => writer.EndSubMessage());

            writer.StartSubMessage("test", null);
            Assert.Throws<InvalidOperationException>(() => writer.EndMessage());
        }
        public void SubMessageAsValueHandled()
        {
            var subMsg = context.NewMessage(new Field("a", 1));
            var stringWriter = new StringWriter();
            var writer = new FudgeJSONStreamWriter(context, stringWriter);

            writer.StartMessage();
            writer.WriteField("test", null, null, subMsg);
            writer.EndMessage();

            string s = stringWriter.ToString();
            AssertEqualsNoWhiteSpace("{\"test\" : {\"a\" : 1} }", s);
        }