public void RegisterEmptyCollectionOfISerializationConverters()
        {
            var loggerMock = new Mock <ILogger>();

            var serializer = new JsonNetSerializer(loggerMock.Object);

            serializer.RegisterSerializationConverters(Enumerable.Empty <ISerializationConverter>());
        }
        public void ThrowWhenRegisterNullCollectionOfISerializationConverters()
        {
            var loggerMock = new Mock <ILogger>();

            var serializer = new JsonNetSerializer(loggerMock.Object);

            Assert.Throws <ArgumentNullException>(() => serializer.RegisterSerializationConverters(null));
        }
        public void RegisterISerializationConverters()
        {
            var loggerMock = new Mock <ILogger>();

            var converter1 = new Mock <ISerializationConverter>();
            var converter2 = new Mock <ISerializationConverter>();

            var serializer = new JsonNetSerializer(loggerMock.Object);

            serializer.RegisterSerializationConverters(new[] { converter1.Object, converter2.Object });
        }
Beispiel #4
0
        /// <summary>
        /// Instantiates an instance of <see cref="ISerializer"/>.
        /// </summary>
        /// <returns>A <see cref="ISerializer"/> instance resolved by one of the <see cref="IServiceLocator"/>s, otherwise <see cref="JsonNetSerializer"/> (leveraging <see href="http://json.codeplex.com/">Json.Net</see>).</returns>
        public ISerializer InstantiateSerializer()
        {
            ISerializer result;

            if (TrySingleInstanceFromServiceLocators(out result))
            {
                return(result);
            }

            result = new JsonNetSerializer(InstantiateLogger());
            result.RegisterSerializationConverters(InstantiateSerializationConverters());

            return(result);
        }