/// <summary>
        /// Tests the failed registration, when we write type name after the header.
        /// </summary>
        private static void TestFailedRegistration <T>(bool rawStr, bool rawInt) where T : ITest, new()
        {
            // Disable compact footers for local mode
            var cfg = new BinaryConfiguration {
                CompactFooter = false
            };

            // Test in local mode so that MarshallerContext can't propagate type registration.
            var bytes = new Marshaller(cfg).Marshal(new T {
                Int = 1, Str = "2"
            });

            var res = new Marshaller(cfg).Unmarshal <T>(bytes);

            Assert.AreEqual(1, res.Int);
            Assert.AreEqual("2", res.Str);

            // Check binary mode
            var bin = new Marshaller(cfg).Unmarshal <IBinaryObject>(bytes, BinaryMode.ForceBinary);

            if (!rawStr)
            {
                Assert.AreEqual("2", bin.GetField <string>("Str"));
            }

            if (!rawInt)
            {
                Assert.AreEqual(1, bin.GetField <int>("Int"));
            }

            res = bin.Deserialize <T>();

            Assert.AreEqual(1, res.Int);
            Assert.AreEqual("2", res.Str);
        }