public void NoContentTypeFallsBackToDefaultSerialization()
        {
            var defaultSerializer = new FakeSerializer(ContentTypes.Xml);
            var resolver = new MessageDeserializerResolver(defaultSerializer, new IMessageSerializer[]
            {
                new FakeSerializer(ContentTypes.Json)
            });

            var serializer = resolver.Resolve(new Dictionary<string, string>());

            Assert.AreEqual(defaultSerializer, serializer);
        }
        public void NoContentTypeFallsBackToDefaultSerialization()
        {
            var defaultSerializer = new FakeSerializer(ContentTypes.Xml);
            var resolver          = new MessageDeserializerResolver(defaultSerializer, new IMessageSerializer[]
            {
                new FakeSerializer(ContentTypes.Json)
            });

            var serializer = resolver.Resolve(new Dictionary <string, string>());

            Assert.AreEqual(defaultSerializer, serializer);
        }
        public void UnknownContentTypeFallsBackToDefaultSerialization()
        {
            var defaultSerializer = new FakeSerializer(ContentTypes.Xml);
            var resolver = new MessageDeserializerResolver(defaultSerializer, new IMessageSerializer[]
            {
                new FakeSerializer(ContentTypes.Json)
            });

            var headers = new Dictionary<string, string>
            {
                {Headers.ContentType, "unknown/unsupported"}
            };
            var serializer = resolver.Resolve(headers);

            Assert.AreSame(defaultSerializer, serializer);
        }
        public void UnknownContentTypeFallsBackToDefaultSerialization()
        {
            var defaultSerializer = new FakeSerializer(ContentTypes.Xml);
            var resolver          = new MessageDeserializerResolver(defaultSerializer, new IMessageSerializer[]
            {
                new FakeSerializer(ContentTypes.Json)
            });

            var headers = new Dictionary <string, string>
            {
                { Headers.ContentType, "unknown/unsupported" }
            };
            var serializer = resolver.Resolve(headers);

            Assert.AreSame(defaultSerializer, serializer);
        }
        public void RetrievesSerializerByContentType(string contentType)
        {
            var expectedResolver = new FakeSerializer(contentType);
            var resolver = new MessageDeserializerResolver(new FakeSerializer("default"), new IMessageSerializer[]
            {
                new FakeSerializer("some/content/type"),
                expectedResolver,
                new FakeSerializer("another/content/type")
            });

            var headers = new Dictionary<string, string>
            {
                {Headers.ContentType, contentType}
            };
            var serializer = resolver.Resolve(headers);
            Assert.AreSame(expectedResolver, serializer);
        }
        public void RetrievesSerializerByContentType(string contentType)
        {
            var expectedResolver = new FakeSerializer(contentType);
            var resolver         = new MessageDeserializerResolver(new FakeSerializer("default"), new IMessageSerializer[]
            {
                new FakeSerializer("some/content/type"),
                expectedResolver,
                new FakeSerializer("another/content/type")
            });

            var headers = new Dictionary <string, string>
            {
                { Headers.ContentType, contentType }
            };
            var serializer = resolver.Resolve(headers);

            Assert.AreSame(expectedResolver, serializer);
        }