예제 #1
0
        public void TestChangeDefaultSerialization()
        {
            var           config = new SerializationConfig();
            ISerializer   ser    = new StringSerializer();
            IDeserializer deser  = new StringDeserializer();

            var s = config.GetSerializersForTopic("topicnotfound");

            Assert.That(s,
                        Is.EqualTo(Tuple.Create(ByteArraySerialization.DefaultSerializer, ByteArraySerialization.DefaultSerializer)));

            var d = config.GetDeserializersForTopic("topicnotfound");

            Assert.That(d,
                        Is.EqualTo(Tuple.Create(ByteArraySerialization.DefaultDeserializer, ByteArraySerialization.DefaultDeserializer)));

            config.SetDefaultSerializers(ser, ser);
            config.SetDefaultDeserializers(deser, deser);

            s = config.GetSerializersForTopic("topicnotfound");
            Assert.That(s,
                        Is.EqualTo(Tuple.Create(ser, ser)));

            d = config.GetDeserializersForTopic("topicnotfound");
            Assert.That(d,
                        Is.EqualTo(Tuple.Create(deser, deser)));
        }
예제 #2
0
        public void TestSerializationConfig()
        {
            var           config = new SerializationConfig();
            ISerializer   ser    = new StringSerializer();
            IDeserializer deser  = new StringDeserializer();

            var t1 = Tuple.Create(ser, ser);
            var t2 = Tuple.Create(ser, ser);

            Assert.That(t1, Is.EqualTo(t2));

            var s = config.GetSerializersForTopic("topicnotfound");

            Assert.That(s,
                        Is.EqualTo(Tuple.Create(ByteArraySerialization.DefaultSerializer, ByteArraySerialization.DefaultSerializer)));

            var d = config.GetDeserializersForTopic("topicnotfound");

            Assert.That(d,
                        Is.EqualTo(Tuple.Create(ByteArraySerialization.DefaultDeserializer, ByteArraySerialization.DefaultDeserializer)));

            config.SetSerializersForTopic("topicnotfound", ser, ser);
            config.SetDeserializersForTopic("topicnotfound", deser, deser);

            s = config.GetSerializersForTopic("topicnotfound");
            Assert.That(s, Is.EqualTo(Tuple.Create(ser, ser)));

            d = config.GetDeserializersForTopic("topicnotfound");
            Assert.That(d, Is.EqualTo(Tuple.Create(deser, deser)));

            var config2 = new SerializationConfig(config);

            s = config2.GetSerializersForTopic("topicnotfound");
            Assert.That(s, Is.EqualTo(Tuple.Create(ser, ser)));

            d = config2.GetDeserializersForTopic("topicnotfound");
            Assert.That(d, Is.EqualTo(Tuple.Create(deser, deser)));

            config2.SetSerializersForTopic("topicnotfound", null, ser);
            config2.SetDeserializersForTopic("topicnotfound", null, deser);

            s = config2.GetSerializersForTopic("topicnotfound");
            Assert.That(s, Is.EqualTo(Tuple.Create(ByteArraySerialization.DefaultSerializer, ser)));

            d = config2.GetDeserializersForTopic("topicnotfound");
            Assert.That(d, Is.EqualTo(Tuple.Create(ByteArraySerialization.DefaultDeserializer, deser)));

            config2.SetSerializersForTopic("topicnotfound", ser, null);
            config2.SetDeserializersForTopic("topicnotfound", deser, null);

            s = config2.GetSerializersForTopic("topicnotfound");
            Assert.That(s, Is.EqualTo(Tuple.Create(ser, ByteArraySerialization.DefaultSerializer)));

            d = config2.GetDeserializersForTopic("topicnotfound");
            Assert.That(d, Is.EqualTo(Tuple.Create(deser, ByteArraySerialization.DefaultDeserializer)));
        }